G
Guest
I wish to dynamically create a context menu of uncertain length, the
uncertainty depending on the number of records in a database. As of right
now what I am doing is adding a number of instances of menuItem to the
context menu cm1. Each instance, when added, is linked to the handler
menuItemMain_click.
Here's menuItemMain_Click. This seems to work but is there a simpler way to
identify the index of the clicked menu item?
---------------------------------------
Private Sub menuItemMain_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
For i = 0 To cm1.MenuItems.Count - 1
If sender Is cm1.MenuItems(i) Then
MsgBox("Here I am " & i.ToString)
Exit Sub
End If
Next
End Sub
uncertainty depending on the number of records in a database. As of right
now what I am doing is adding a number of instances of menuItem to the
context menu cm1. Each instance, when added, is linked to the handler
menuItemMain_click.
Here's menuItemMain_Click. This seems to work but is there a simpler way to
identify the index of the clicked menu item?
---------------------------------------
Private Sub menuItemMain_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
For i = 0 To cm1.MenuItems.Count - 1
If sender Is cm1.MenuItems(i) Then
MsgBox("Here I am " & i.ToString)
Exit Sub
End If
Next
End Sub