Link to home
Start Free TrialLog in
Avatar of ramrocket
ramrocket

asked on

Label On PictureBox

I have a few labels on a picturebox.  I want them to have trasparent background.
I set the label color to Transparent but doesnt work.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You need to set the Parent of the Label to the PictureBox for the transparency to work:

            label1.BackColor = Color.Transparent;
            label1.Parent = pictureBox1;
            label1.Location = new Point(25, 25);
Avatar of ramrocket
ramrocket

ASKER

I did this

label1.BackColor = Color.Transparent; = in design mode
           
label1.Parent = pictureBox1; = did this at runtime but my label does not display anymore
You probably need to adjust the LOCATION of the label.

It's location at design-time is relative to the FORM.

When you set its Parent to the PictureBox, it keeps the same location but becomes relative to the origin of the PictureBox.  This location may be out of the visible bounds of the PictureBox...

This is why I showed the last line of code in my example:

            label1.BackColor = Color.Transparent;
            label1.Parent = pictureBox1;
            label1.Location = new Point(25, 25);
how do I set the new location thesame location during design time?
I can see the label after setting the new location but its position is way off
The PictureBox control cannot be a container at design-time, but it can be at run-time (with the Parent call).

Bob
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mind, that works - thanks alot