transparency of controls in vb.net

nakracreative

Well-known member
Joined
Aug 1, 2005
Messages
72
Location
India
Programming Experience
1-3
Can someone help me out in making a control behave as transparent control on windows form. color.transparent only makes it with respect to the form but i want the control to behave as a transaprent control with respect to every other control placed on the form.
 
Last edited:
Sorry, it seems as though that's not possible with controls (labels as I've noticed from other posts). Setting the control's BackColor property to Color.Transparent only causes the control to paint the portion of it's parent's background as its background.
It seems that you'll have to resort to GDI+. But fear not, GDI+ is not that difficult.
 
Certainly!
I realize that you are attempting to have at least two labels that overlap both show their entire text content. Knowing why you are doing this may lead to a better solution but...

What I have done in the past is to create a class that is passed the parenting Form's instance when instantiated. Then you can have the class handle the Form's Paint event. The class would in the least have properties for location, size and text. In the class's Paint event (the one that's actually handling the Form's Paint event) you would use the graphics object of the System.Windows.Forms.PaintEventArgs and it's DrawString method to paint the text contained in the new class's Text property.

Sorry for the longwindedness, just look into the System.Drawing.Graphics.DrawString method.
 
Back
Top