Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opacity on Control

Tags:

c#

winforms

Is it possible to make a control semi-transparent?

like image 564
Codler Avatar asked Feb 21 '11 10:02

Codler


2 Answers

The direct answer to your question is 'No'.

WinForms supports Translucency at the Form level (Form.Opacity), but not controls. In cases this was important, I have used layered forms.

If this feature is important and changing frameworks is an option, WPF does support translucent controls.

like image 100
John Arlen Avatar answered Nov 08 '22 12:11

John Arlen


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 (to between 0 and 255).

like image 31
Xander Avatar answered Nov 08 '22 13:11

Xander