Luiscencio
Luiscencio

Reputation: 3965

How can I change Control's Opacity?

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

Upvotes: 6

Views: 12230

Answers (2)

Joel Mueller
Joel Mueller

Reputation: 28764

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

Upvotes: 2

user27414
user27414

Reputation:

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

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

Depending on how you want this to work, you would vary the alpha value based on mouse position (to between 0 and 255).

Upvotes: 5

Related Questions