transparent labels on pictureboxes

P

Pascal

Je veux que mes label soit transparent aussi sur mes picturebox alors
j'écris :
i want my labels to be transparent on my pictureboxes so i wrote :

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Label1.Parent = PictureBox1
Label1.BackColor = Color.Transparent
Label2.Parent = PictureBox2
Label2.BackColor = Color.Transparent
End Sub

ça marche nickel pour label1 mais pas pour label2....
it works fine for label1 but not for label12

Pourquoi ? J'ai fait exactement la même manip...
why ? I did the same thing for the two labels...

someone has got an idea ?
thanks
pascal
 
A

ag

Put these lines after your mentioned code:

Label1.Location=New Point(1,1)
Label2.Location=New Point(1,1)

Then you can see your labels. :)

The problem was, when u r assigning a label to new parent, it will
calculate some relative position depending on the label's previous
parent's Location i.e. the Form itself. Surprisingly the labels were
there and u coudnt see it becoz ur picturebox is small. Resize ur both
picture box to big, then u can see ur labels OR u assign label to new
location (i.e. 1,1 or anything ) RELATIVE TO picturebox i.e. its new
parent.

Regards,
ag
 
P

Pascal

woah you did it !!!!!! i spent a lot of time about this.... suspecting a bug
around png file etc.... aaargh!
now it's perfect ! thanks to be so fast !

here is the code
:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Label1.Parent = PictureBox1

Label1.BackColor = Color.Transparent

Label2.Parent = PictureBox2

Label2.BackColor = Color.Transparent

Label2.Location = New Point(19, 15)

Label3.Parent = PictureBox2

Label3.BackColor = Color.Transparent

Label3.Location = New Point(110, 15)

Label4.Parent = PictureBox2

Label4.BackColor = Color.Transparent

Label4.Location = New Point(196, 15)

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Label1.Parent = PictureBox1

Label1.BackColor = Color.Transparent

Label2.Parent = PictureBox2

Label2.BackColor = Color.Transparent

Label2.Location = New Point(19, 15)

Label3.Parent = PictureBox2

Label3.BackColor = Color.Transparent

Label3.Location = New Point(110, 15)

Label4.Parent = PictureBox2

Label4.BackColor = Color.Transparent

Label4.Location = New Point(196, 15)

End Sub



http://www.scalpa.info
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top