[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Label On PictureBox

Posted on 2006-05-10
8
Medium Priority
?
687 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:ramrocket
  • 4
  • 3
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16650613
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
 

Author Comment

by:ramrocket
ID: 16650713
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16650761
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ramrocket
ID: 16650781
how do I set the new location thesame location during design time?
0
 

Author Comment

by:ramrocket
ID: 16650800
I can see the label after setting the new location but its position is way off
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16650855
The PictureBox control cannot be a container at design-time, but it can be at run-time (with the Parent call).

Bob
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 16650857
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
 

Author Comment

by:ramrocket
ID: 16650923
mind, that works - thanks alot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question