Opacity of Buttons/TextBoxes - VB.NET

这一生的挚爱 提交于 2019-12-04 07:33:40

There is no way to set the opacity of any control in WinForms. Only Forms have the opacity property. If you want to make any control appear semi-transparent, you'll have to implement the whole control from scratch and that will most likely involve drawing the control as an image onto its parent.

Your alternative is to use WPF, which allows setting the opacity of controls.

No, opacity is not a button property, it's inherited from whatever the form is set to. I don't know of any way of doing this short of "faking it" by using an image of a button faded to appear translucent.

Just set the Alpha level in your RGBA setting for the color of the control. The code will look something like this:

Control.Backcolor = Color.FromArgb(255, 255, 255, 255)

The first value passed into the FromArgb method is the Alpha. A high value will mean high opacity whereas a low value will mean a high transparency. You may need to set the control's Forecolor property as well if you want that to be transparent, too.

On your form that the control rests on, set TransparencyKey to a color (ex: Fuchsia), then make your control's background color as Fuchsia. You're welcome.

<asp:ImageButton ID="avbtn" runat="server" Height="55px" 
ImageUrl="~/images/avatar.jpg"                                             
onmouseout="this.style.opacity=0.7;this.filters.alpha.opacity=40" 
onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" 
style="opacity:0.4;filter:alpha(opacity=40)" />

This one works fine for an ImageButton,but I haven't tested it on anything else.

I think you can fade a panel if you put a button in one.

ur_Auror

What I did is to edit my own button (must be an image) on Photoshop, and there, I lower its opacity. So once I put my image on the form (which is my button), it looked like I applied opacity in it. Like this:

Easy way: Select a random colour of the textbox you want to make transparent by going to it's property-backcolor-any. Then come to the source and find the colour code of the colour you have chosen and write transparent and you are done. Ex:

<asp:TextBox ID="TextBox1" 
 runat="server" **BackColor="transparent"** Height="55px" Width="498px"> </asp:Textbox>  

Same for VB as well. Cheers!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!