Transparent BackStyle for label

E

Elmo Watson

In the 'good old days' of vb6, labels had a 'BackStyle' property - you could
set them Opaque or Transparent.

I have a need for the Transparent attribute - - in VB.Net (2005), how can
this be accomplished?
 
J

Jimmy J.

I initially thought the same thing, however, it doesn't work - it just gives
a white background
 
C

ClayB

Label supports a transparent background, but some controls do not (ie,
textbox).
If I set a form's BackgroundImage property and then drop a Label on
the form and set its BackColor as:

label1.BackColor = Color.Transparent

then the bitmap background of the form shows through the label as
expected.

====================
Clay Burch
Syncfusion, Inc.
 
E

ElmoWatson

Totally understood - - -
In this case, the entire form has a fully docked PictureBox with an image.

(I haven't tried setting the Transparency in code) I set the background
color of the label (on top of the picturebox) to transparent, using the
Properties window. I would expect the image (as you say) to show through the
label. However, instead of this, it shows a murky white color as the
background.

could it be because I'm using the picture box, instead of making the image
be the background image of the form?
 
C

Chris Dunaway

Totally understood - - -
In this case, the entire form has a fully docked PictureBox with an image.

(I haven't tried setting the Transparency in code) I set the background
color of the label (on top of the picturebox) to transparent, using the
Properties window. I would expect the image (as you say) to show through the
label. However, instead of this, it shows a murky white color as the
background.

could it be because I'm using the picture box, instead of making the image
be the background image of the form?

When you set the background color of the label to Transparent, what
shows through it the Label's container. It's not a true transparent
label.

When you drag a label on top of a PictureBox, the Label's container is
still the form and not the picturebox. You need to set the parent
property of the label to the PictureBox then the PictureBox should
show through the label.
 

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