Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hai
i am developing windows application,in that i create buttons dynamically with move options.actually i have form ,in that i put panel with backroundimage as Dock=Fill,in panel i am create buttons dynamically,i need to make buttons as transparent,i.e i need to see panel image via buttons as created dynamically.so need to make button as transparaent.
i am try this
VB
Dim btn As New Button
btn.Parent = Me.ContainerSLD
Dim buttonBackground As New Bitmap(btn.Width, btn.Height)
Using g As Graphics = Graphics.FromImage(buttonBackground)
    g.DrawImage(Me.ContainerSLD.BackgroundImage, New Rectangle(0, 0, buttonBackground.Width, buttonBackground.Height), btn.Bounds, GraphicsUnit.Pixel)
End Using
btn.BackgroundImage = buttonBackground


but it not change transparaent.
pls reply me asap

Regards
Aravind
Posted
Updated 20-Feb-16 10:30am

just set the flatstyle to Flat, and the background color to transparent?
 
Share this answer
 
Comments
Aravindba 17-Dec-13 1:04am    
i am create button run time,not in design time
farhad Najib 17-Dec-13 1:30am    
I Think this solution is OK.Set these properties by code on runtime.
Aravindba 17-Dec-13 2:40am    
sorry,i didnt test before reply,actually i read some points in forums,if we change backcolor in design time it will not work,but now i tezt it will work what i need,
may be

1.remove
VB
btn.BackgroundImage = buttonBackground


2.write
VB
btn.BackColor=color.Transparent
 
Share this answer
 
Comments
Aravindba 17-Dec-13 1:06am    
already try this,not work,i will create button dynamically,so i add click event,name,text,tag,size.location,any of this affect backcolor=color.Transparent.Actually i am use background as panel not picture box.if it picture then it work,but i need background as panel with bacground image,bcz in picture box grag and drop properties not available,if i create in runtime also not work
try this
Dim alpha AS Int16
alpha = 60
Button1.BackColor = Color.FromARGB(alpha,SystemColor.Control)
 
Share this answer
 
Comments
Aravindba 17-Dec-13 2:31am    
no not work, and also it show error in SystemColor ,need to change SystemColors ,but not work
Let's try with this

Button1.BackColor = Color.Fromargb(160, 64, 64, 64)

Maybe that works
 
Share this answer
 
Comments
Aravindba 21-Feb-16 0:06am    
thanks for ur reply,but this post was posted on 2013 and it solved on that year,before reply pls check when was question asked and any reply accepted as solution,but may be ur answer useful others if they face same problem
Sammy BM 18-Mar-16 15:16pm    
Your welcome, sorry i don't know it has been posted on 2013

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900