The reason the label "disappears" may be due to the use of an absolute label location X and Y values after the Picturebox is made the parent.

Try this:


        'Make labels transparent and set locations 

        With Label3
            .Text = "A"
            '.Location = New Point(62, 39)
            .Location = New Point(.Location.X - PictureBox1.Location.X, .Location.Y - PictureBox1.Location.Y)
            .ForeColor = Color.DimGray
            .BackColor = Color.Transparent
            .Parent = PictureBox1
        End With`

This may work if called only once upon initial Form Load, but if called a second time, the location calculation may give unpredictable results.

2 Years
Discussion Span
Last Post by Shark_1

Are you sure of the location that it correct? And also if you say if calling it secondly you mean you have a code for it in Form load and also some where else?


PictureBox is the Parent Control of the Label, So I think that no need to use the methods PictureBox1.SendToBack() and .BringToFront(). Remove them.

Your problem is in calculation of the location of the label. Simply store the location in a point variable. If you want to display at same position assign the variable to the location property.

        Dim pnt As New Point
        With Label3
            pnt.X = .Location.X
            pnt.Y = .Location.Y

            .Text = "A"
            .Location = New Point(pnt.X , pnt.Y)
            .ForeColor = Color.DarkGray
            .BackColor = Color.Transparent
            .Parent = PictureBox1
        End With

Hope it should help you.

Edited by Shark_1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.