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.
I set the label color to Transparent but doesnt work.
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
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);
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);
ASKER
how do I set the new location thesame location during design time?
ASKER
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
Bob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mind, that works - thanks alot
label1.BackColor = Color.Transparent;
label1.Parent = pictureBox1;
label1.Location = new Point(25, 25);