1

How to put transparency on certain element on windows form?

I have tried a lot of codes and still nothing.

This is what looks really logical to me but it's not working.

 SetStyle(ControlStyles.SupportsTransparentBackColor, true);
 label4.BackColor = Color.Transparent;

I have put this code in the constructor.

And this is the LINK

user123_456
  • 5,635
  • 26
  • 84
  • 140

3 Answers3

2

Labels are a bit stubborn but they can be made to have transparent background. Similar question was answered here: Transparent control over PictureBox

Community
  • 1
  • 1
Maciej
  • 7,871
  • 1
  • 31
  • 36
0

try adding this to the form itself...

this.TransparencyKey = System.Drawing.Color.Transparent;

You'd think it would be inherent, but in testing adding that did the trick. Then set the control to this...

Label1.BackColor = System.Drawing.SystemColors.Window;

That just worked in a test project not really sure why exactly. This will probably make most of your form transparent, but hopefully you can adjust some things.

Kevin DiTraglia
  • 25,746
  • 19
  • 92
  • 138
0

Winforms do not have built in transparency for controls. You can, however work around this limitation.

Here is my favorite work around: http://www.doogal.co.uk/transparent.php
It works fairly well and is a generic solution rather then a "1 time" one.

  • additionaly, WPF handles transparency quite well, you could at least take a look at it –  May 18 '12 at 21:13