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 :)

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

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.