I was just experimenting with windows forms and came across the property Opacity
. I made a very simple program containing a form with a textbox and added the following code:-
this.textBox1.MouseHover += ChangeOpacity ;
private void ChangeOpacity(object sender, EventArgs e )
{
this.Opacity = 50 ;
this.Refresh() ;
}
I want to change the opacity of the the form to 50% when the user hovers it's mouse over the textbox, but this code is not working. The opacity still remains at 100%. Can anyone point out the mistake I am doing in the above code, or what should I do to correct my problem. I also tried using Invalidate()
ans then Update()
but it is still not changing the opacity.
The Opacity
would be in percentage. The default would be 1.00
Try putting:
this.Opacity = 0.5;
Opacity goes in the values from 0 to 1
so 100 % would be a 1 and 50 % would be a .5 and 0% would be a 0.
try with it
this.Opacity=.5;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.