Panel

Posts 1–5 of 5 · Page 1 of 1
Panel
Hi at MPGH i have a question

when i add a panel like this:
Code:
di p as new panel
FormLayoutPanel1.controls.add(p)
how can i add a code for the panel (p)
like when i click on the panel a messagebox should pop up

please help me
use the Click event of it
This one

Code:
Private Sub Panel1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.Click
msgbox ("enter text")
    End Sub
Withevents p as new panel
thanks Blubb1337
Or use the "AddHandler" operator to apply a handler to an event.

[highlight=vb.net]
Dim p As New Panel()
p.Name = "helloJoe"
Me.Controls.Add(p)
AddHandler p.Click, AddressOf myHandler
[/highlight]

And the delegate:
[highlight=vb.net]
Private Sub myHandler(ByVal sender As Object, ByVal e As EventArgs)
Dim sendingPanel As Panel = Ctype(sender, Panel) 'identify which panel sent the event.
MessageBox.Show(String.Format("A panel with name '{0}' triggered this event.", sendingPanel.Name), "Info: Panel was clicked")
End Sub
[/highlight]
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Talk with us