runtime created panels

hi again

how can i get the selected panel from runtime created panels on click event

I mean I have created 5 different panel on a form's runtime. Each of them has a label, too. If i click on one of the panels I want a messagebox to write the text of the label.

Only vb2005 codes, plz. thnx




Answer this question

runtime created panels

  • Dedy Susanto

    Hi,

    You should create MouseClick event handler like shown below and associate it with all the panels' MouseClick event:

    Private Sub Panel_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseClick, Panel2.MouseClick

    Dim sourcePanel As Panel
    sourcePanel = sender
    MessageBox.Show(sourcePanel.Controls.Item(0).Text)

    End Sub



  • B-RETT

    thnx a lot! :)

  • runtime created panels