Larry Brister
asked on
WinForms - Back in the saddle
I have a project with a main form
The main form has a telerik menu system, and on Menu Item CLick I'll be loading user controls
The following in my Code.
What I would like to do is also set a variable on click event which I can pass into the user control.
I've been working on Web Forms the last 5 years and rusty on WinForms and passing variables.
My Code:
The main form has a telerik menu system, and on Menu Item CLick I'll be loading user controls
The following in my Code.
What I would like to do is also set a variable on click event which I can pass into the user control.
I've been working on Web Forms the last 5 years and rusty on WinForms and passing variables.
My Code:
Private Sub HomeMenu_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles HomeMenu.ItemClicked
'Unload any existing Control
If Me.mainPanel.Controls.Count > 0 Then
Me.mainPanel.Controls.RemoveAt(0)
End If
'Declare a contrl for use
Dim _panel As New Control
_panel = New ucDefault
'Actions based on menu clicked
Select Case e.ClickedItem.Text.ToString()
Case "Home"
pbApplication.Image = ngMan.My.Resources.Bookmark
Case "Email"
pbApplication.Image = ngMan.My.Resources.emailMain
Case "CliMan"
pbApplication.Image = ngMan.My.Resources.hospitalMain
Case "CanMan"
pbApplication.Image = ngMan.My.Resources.nurseMain
Case "NG Man"
pbApplication.Image = ngMan.My.Resources.receptionist
Case "HoursMan"
pbApplication.Image = ngMan.My.Resources.hoursMain
Case "CalcMan"
pbApplication.Image = ngMan.My.Resources.calcMain
Case "LodgeMan"
pbApplication.Image = ngMan.My.Resources.office_building_icon
_panel = New ucLodgeMan
Case Else
pbApplication.Image = ngMan.My.Resources.Bookmark
End Select
Me.mainPanel.Controls.Add(_panel)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could also make your UserControl to raise a CUSTOM EVENT that passes out information when it is clicked. Again, you'd use AddHandler() when you create that UserControl to wire up that custom event...
ASKER
Thanks
"I'll be loading user controls"
"I would like to ... set a variable on click event"
Do you need to wire up a click event for your user control? If yes, use AddHandler():
Open in new window
See AddHandler(): http://msdn.microsoft.com/en-us/library/7taxzxka(VS.80).aspx