0

ok so i have a controle that is made when a user clicks on an image:

Sub newbox(ByVal x As Integer, ByVal y As Integer, ByVal text As String)
        PictureBox1.SendToBack()
        Try
            Dim PB As New PictureBox
            With PB
                .Name = text
                '.BackColor = Color.Red
                .Image = Image.FromFile("point.jpg")
                .SizeMode = PictureBoxSizeMode.Zoom
                .Location = New System.Drawing.Point(x, y)
                .Size = New Size(3, 3)
            End With
            RemoveHandler PB.MouseHover, AddressOf MyPicClicked
            RemoveHandler PB.MouseLeave, AddressOf myPicOut
            AddHandler PB.MouseHover, AddressOf MyPicClicked
            AddHandler PB.MouseLeave, AddressOf myPicOut
            Me.PictureBox1.Controls.Add(PB) 'Added to the correct parent
            PB.BringToFront()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

i have many of these there like points on a map i want it so when the user clicks on them again they are deleted thanks in advanced :)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by GeekByChoiCe
0

u can use:

Dim btnToDelete As Control = GetChildAtPoint(New Point(x, y), GetChildAtPointSkip.Invisible)
Me.Controls.Remove(btnToDelete )

replace x and y with the current click location

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.