English 中文(简体)
Opacity of Buttons/TextBoxes - VB.NET
原标题:

Is it possible to set the opacity of a button or textbox? I know that you can set the opacity for a form, but I m not so sure about a button or textbox.

问题回答

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.

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

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:

<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.

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!!!





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签