I searched, but have no clue what to do. I have a small picturebox(34x34 pixels) and want to have a transparent label(maybe 12x12 or 15x15 pixels) in the corner of it, which will be used as a counter.

I saw another forums suggesting adding the PictureBox as a parent to the Label, like this:

Label1.Parent = PictureBox1
Label1.BackColor = Color.Transparent

But then the label just disappears, and no text is displayed.

Recommended Answers

All 10 Replies

Label1.Parent = PictureBox1
        Label1.BackColor = Color.Transparent
        Label1.BringToFront()
        Label1.Location = New Point(20, 20)
commented: Excellent. I had the same idea, but missed that Location point, damn :) +2

Thanks, tried that but I still can't see any text.

For some reason it actually does work. Have you tried to change the text's color: Label1.ForeColor = Color.White ?

Here's the code I tested and it works fine

Label2.Parent = PictureBox1
Label2.BackColor = Color.Transparent
Label2.BringToFront()
Label2.ForeColor = Color.White
Label2.Text = "foo bar"
Label2.Location = New Point(20, 20)

PictureBox1.Image = Image.FromFile("D:\image.jpg")

The key, apparently, is the line:
Label2.Parent = PictureBox1

Before doing that, I had the same problem. Adding that single line fixed the issue. Interestingly, that "parent" property doesn't seem to be exposed to the VB 2008 IDE, but it does show up in intellisense.

I'm no longer working on this project, so consider it closed, thanks for trying guys.

label1.autosize=true

thanxxxxxxxxxxxxxx

Lulz, just use a panel as a picturebox : ) had the same problem.

This will work folks,
LblInit.Parent = PbAnimated

   LblInit.Parent = PbAnimated
        LblInit.AutoSize = True
        LblInit.Location = New Point(0, 0)
        LblInit.BackColor = Color.Transparent
        LblInit.BringToFront()
        LblInit.ForeColor = Color.Black
        LblInit.Text = "Initialising..Please wait..."


    LblInit.Location = New Point(0, 0)
    LblInit.BackColor = Color.Transparent
    LblInit.BringToFront()
    LblInit.ForeColor = Color.Black
    LblInit.Text = "Initialising..Please wait..."
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.