David
David

Reputation: 16028

Transparent controls in .NET

I have a problem with:

BackColor = Color.Transparent;

It's not working correctly. I have a form with a blue background, and a picturebox with a picture loaded in it. It's not actually taking what's in the picture, but rather - the form's background color. Please tell me there's a simple way to go around this?

What you see in the following screenshot is a custom usercontrol with it's backColor set to transparent, on top of a picture, in a form with a blue background.

I need the usercontrol to display what's UNDER it, as real transparency, it should be showing the gradient and part of the image.

enter image description here

Upvotes: 2

Views: 868

Answers (2)

eyossi
eyossi

Reputation: 4330

Try calling "SetStyle(ControlStyles.SupportsTransparentBackColor, true);" on your user control constructor.

more details at: http://msdn.microsoft.com/en-us/library/wk5b13s4(v=vs.90).aspx

Upvotes: 0

ean5533
ean5533

Reputation: 8994

Try setting the picture box to be the parent of the custom user control.

myControl.Parent = this.myPictureBox;

Upvotes: 3

Related Questions