Label->Color->Transparent, problem

LOFRANK

Well-known member
Joined
Aug 26, 2003
Messages
49
Location
Naples
when i put a label on a panel witch have a background image , i put the background color of the label Transparent for see just the text on the panel, but it show the background of the form, how to fix?
 
When the background of a label is set to transparent, the labels CONTAINER is drawn behind the transparent label, but no other controls. If you can see through the label to the form, perhaps the label isnt INSIDE the panel, NOT ON TOP. If this is the case then the form will be drawn through the label, but not the panel (it will look like the label cuts a hole in the panel).

You DO NOT need to draw the text manually (everyone seems to think otherwise). You just need to make sure that the control is actually inside what you want to show through the transparent control. If what you want to appear behind the transparent label is not a control container (and a panel IS a control container) and you cant substitute a control container control for what you are using, then in that case, YES, you do need to do it manually with the Graphics class.
 
I think that most all controls have a controls properity which you can access and add transparent labels.
Code:
        With Label2
            .Location = New Point(20, 20)
            .BackColor = Color.Transparent
            .BringToFront()
        End With
        PictureBox1.Controls.Add(Label2)

BUT...You have a lot more graphic options if the text is directly drawn onto the container control.
 
In VB6, picture boxes could contain other controls. In .NET, the picturebox can not. Only container controls and scrollable controls can contain other controls (for example, panels and group boxes)
 
I think if you do a cut and paste with my code youll be suprised.

But...drawing the text directly onto the picture box will afford a lot more options, and is easy enough to do.
 
Surprised indeed. This is contrary to the behavior I expected after reading about container controls in msdn.
 
I havent tried it yet (I prefer to paint text onto objects rather than use transparent labels for many reasons) but I think that since all .NET controls are objects that this should work for all controls.
 
I dont understand what you mean... of course all controls are objects. Everything in .NET derives from the object class. What does that have to do containing other controls?
 
you could try to override the background painting of the textbox and paint a paece of the background image of the parent object that way you will have that transparent look you might look fore
 
Back
Top