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.
ramrocketAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Right...I assume you have the Label positioned over the PictureBox at design-time?

Assuming that they are both contained by the FORM:

            label1.BackColor = Color.Transparent;
            label1.Location = new Point(label1.Left - pictureBox1.Left, label1.Top - pictureBox1.Top);
            label1.Parent = pictureBox1;
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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);
0
 
ramrocketAuthor Commented:
I did this

label1.BackColor = Color.Transparent; = in design mode
           
label1.Parent = pictureBox1; = did this at runtime but my label does not display anymore
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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);
0
 
ramrocketAuthor Commented:
how do I set the new location thesame location during design time?
0
 
ramrocketAuthor Commented:
I can see the label after setting the new location but its position is way off
0
 
Bob LearnedCommented:
The PictureBox control cannot be a container at design-time, but it can be at run-time (with the Parent call).

Bob
0
 
ramrocketAuthor Commented:
mind, that works - thanks alot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.