user123_456
user123_456

Reputation: 5805

transparency of form controls in c#

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

Upvotes: 1

Views: 1134

Answers (3)

Maciej
Maciej

Reputation: 7971

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

Upvotes: 2

user1241335
user1241335

Reputation:

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.

Upvotes: 0

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26078

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.

Upvotes: 0

Related Questions