V
Vinay
Hi,
I have created a Context Menu class (CMenu) with relevant
items. Based on a selected Item, I am taking a separate
action. The following code is working fine.
CMenu(sOption as string)
....
TM = New ContextMenu
TM.MenuItems.Add("Case 1", AddressOf mItems)
TM.MenuItems.Add("Case 2", AddressOf mItems)
....
Private Sub mItems(ByVal sender As Object, ByVal e As
EventArgs)
Dim iClicked as new MenuItem
iClicked = CType(sender, MenuItem)
Select Case iClicked.Text
Case "1"
Msgbox iClicked.Text & "1"
Case "2"
Msgbox iClicked.Text & "2"
......
End Select
....
End Sub
Now I want to use an external parameter (string 'sOption'
passed to the class CMenu) in the sub mItems(). How can I
pass this parameter to this sub, as Addressof mItems
(sOption) is throwing an error. I don't want to use a
global variable.
Regards
Vinay
I have created a Context Menu class (CMenu) with relevant
items. Based on a selected Item, I am taking a separate
action. The following code is working fine.
CMenu(sOption as string)
....
TM = New ContextMenu
TM.MenuItems.Add("Case 1", AddressOf mItems)
TM.MenuItems.Add("Case 2", AddressOf mItems)
....
Private Sub mItems(ByVal sender As Object, ByVal e As
EventArgs)
Dim iClicked as new MenuItem
iClicked = CType(sender, MenuItem)
Select Case iClicked.Text
Case "1"
Msgbox iClicked.Text & "1"
Case "2"
Msgbox iClicked.Text & "2"
......
End Select
....
End Sub
Now I want to use an external parameter (string 'sOption'
passed to the class CMenu) in the sub mItems(). How can I
pass this parameter to this sub, as Addressof mItems
(sOption) is throwing an error. I don't want to use a
global variable.
Regards
Vinay