Why won't label background actually set to transparent?
http://i69.photobucket.com/albums/i53/adwins04/summary.jpg
http://i69.photobucket.com/albums/i53/adwins04/properties.jpg
In the picture it is the label that says Summary.
http://i69.photobucket.com/albums/i53/adwins04/summary.jpg
http://i69.photobucket.com/albums/i53/adwins04/properties.jpg
In the picture it is the label that says Summary.
Whats the control on which summary is sitting on? (panel? form?)
try control->right click 'send to back' .
The transparent property for the label control actually works quite interestingly. When you set a labels back color to transparent, it IS transparent to other controls on the form, but it will take on the back color of the form itself. For example, if I have a label on top of a picture box. Say the picture box is white, and the labels background is set to transparent. And the forms background is set to control. The label background will be transparent to the picture box, but will take on the back color of the form. Meaning, the label is transparent to everything, BUT the form. The fix for doing this is set the background color of the label to something that you would never normally use such as "hotpink" and set the forms TransparencyKey to "hotpink".
Topic url: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=671233&SiteID=1
It seems that when backcolor=transparent, lable control will use the same way which your form's onpaint method do, to redraw its background.
add a lable "lable1" and set its backcolor to transparent. Try following code, you will notice that the lable redraw its background with a red rectangle on the topleft, the same as the form's onpaint do.
protected override void OnPaint(PaintEventArgs e) { SolidBrush redbrush = new SolidBrush(Color.Red); Rectangle rect = new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width/2 , e.ClipRectangle.Height/2 ); e.Graphics.FillRectangle(redbrush, rect); base.OnPaint(e); } private void Form1_Load_1(object sender, EventArgs e) { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); label1.BackColor = Color.Transparent; } |