In my project, I have two seperate forms and in one of them I can add various panels using a button. After adding let's say 5 panels I click on one of them and I need the code to tell me which panelI clicked on. The reason I need this is to refrence the clicked panel's information on the other form. So if the user clicks on panel 3, the other form shows up and tells me you clicked on panel 3. here's what I have so far.

    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As ClickEventArgs) Handles Button.Click
        For Each Panel In FlowLayoutPanel1.Controls.OfType(Of PanelControl)()
        AddHandler Panel.Click, AddressOf Panel_Click
        Next
    End Sub



    Private Sub Panel_Click(ByVal sender As Object, ByVal e As EventArgs)
        Form.Label.Text = "You clicked on" & sender
        Form.Show()
    End Sub

this should give you hint.Click Here

Thanks man, that did the trick.

--> TryCast(sender, Panel)

Cheers.

Then please mark this thread as solved.

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.