How can I change the opacity of the control?

I want to change the transparency of controls depending on the position of the mouse in the form, is this possible?

+3
source share
2 answers

If the control supports transparent backgrounds, you can use Color.FromArgb()to set the translucent color:

button1.BackColor = Color.FromArgb(100, Color.Red);

Depending on how you want this to work, you will change the alpha value based on the position of the mouse (from 0 to 255).

+5
source

Jon B is right, but you can also do this in the properties window of the WinForms constructor. For example, setting the background color 150, 255, 255, 255will make the background translucent white. The designer translates this in Color.FromArgb(150, 255, 255, 255)for you.

0
source

Source: https://habr.com/ru/post/1727806/


All Articles