ghiboz
ghiboz

Reputation: 8003

c# usercontrol transparency

it's possible to have a usercontrol over my form and set a transparency percentage? I Wish have the background of the usercontrol to 70% transparent, but the buttons and the rest of the components to 100%

it's possible? thanks

Upvotes: 0

Views: 5056

Answers (3)

Derek Tremblay
Derek Tremblay

Reputation: 197

On WPF you can use Opacity property like this

<!-- XAML -->

<!-- 50% Transparency -->
<Label Opacity="0.5"/>

<!-- 80% Transparency -->
<Label Opacity="0.2"/>

Upvotes: 2

Dyppl
Dyppl

Reputation: 12381

Try adding the following to the control's constructor:

base.CreateParams.ExStyle |= 0x20;            
SetStyle(ControlStyles.SupportsTransparentBackColor, true);

BackColor = Color.FromArgb(0x80,0xFF,0xCC,0x33);

Upvotes: 3

Gerrie Schenck
Gerrie Schenck

Reputation: 22368

Try setting a one by one pixel png with the desired transparency (alpha channel) as the background for your button. This should work with WinForms, WPF and webforms.

Upvotes: 3

Related Questions