Label with Transparent Background

G

Guest

I need to have text displayed over a picturebox with an image in it. When
using a label whose BackColor = System.Drawing.Color.Transparent, the
background is not transparent.

I came across this explanation as to why .Net does not support transparent
backgrounds.

************
[In Visual Basic 6.0, the BackStyle property of the Label control determined
whether the label had a transparent background. Setting the BackStyle
property to 0 – Transparent allowed any background image or other controls to
show through the label.

In Visual Basic .NET, the BackStyle property no longer exists, and the
transparency behavior is slightly different. To emulate the transparent
behavior in Visual Basic .NET, set the BackColor property to
System.Drawing.Color.Transparent. This will allow the background image to
show through, but it will not be transparent in regard to other controls.]
**********************

The last phrase is mindboggling, " . . . but it will not be transparent in
regards to other controls." What good it is then??? Why would any lanquage
designer not support such a useful property?

How do I get a label to have a true transparent background??

WR
 
C

Chris

When you set the label to transparent, it is transparent only to its
parent, in this case the form, so it shows the form's background
through the label.

If you want to to show the picture box through the label, you must set
the parent of the label to be the picture box:
Label1.Parent = PictureBox1

Then the label will display properly.
 
T

Thomas Wenning

WhiskyRomeo said:
I need to have text displayed over a picturebox with an image in it. When
using a label whose BackColor = System.Drawing.Color.Transparent, the
background is not transparent.

I came across this explanation as to why .Net does not support transparent
backgrounds.

************
[In Visual Basic 6.0, the BackStyle property of the Label control determined
whether the label had a transparent background. Setting the BackStyle
property to 0 - Transparent allowed any background image or other controls to
show through the label.

In Visual Basic .NET, the BackStyle property no longer exists, and the
transparency behavior is slightly different. To emulate the transparent
behavior in Visual Basic .NET, set the BackColor property to
System.Drawing.Color.Transparent. This will allow the background image to
show through, but it will not be transparent in regard to other controls.]
**********************

The last phrase is mindboggling, " . . . but it will not be transparent in
regards to other controls." What good it is then??? Why would any lanquage
designer not support such a useful property?

How do I get a label to have a true transparent background??

WR

Hi William,

read this:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=2132&lngWId=10

Greeting

Thomas
 
G

Guest

thanks for the link. I going to use this.

wr

Thomas Wenning said:
WhiskyRomeo said:
I need to have text displayed over a picturebox with an image in it. When
using a label whose BackColor = System.Drawing.Color.Transparent, the
background is not transparent.

I came across this explanation as to why .Net does not support transparent
backgrounds.

************
[In Visual Basic 6.0, the BackStyle property of the Label control determined
whether the label had a transparent background. Setting the BackStyle
property to 0 - Transparent allowed any background image or other controls to
show through the label.

In Visual Basic .NET, the BackStyle property no longer exists, and the
transparency behavior is slightly different. To emulate the transparent
behavior in Visual Basic .NET, set the BackColor property to
System.Drawing.Color.Transparent. This will allow the background image to
show through, but it will not be transparent in regard to other controls.]
**********************

The last phrase is mindboggling, " . . . but it will not be transparent in
regards to other controls." What good it is then??? Why would any lanquage
designer not support such a useful property?

How do I get a label to have a true transparent background??

WR

Hi William,

read this:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=2132&lngWId=10

Greeting

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top