Hi all, I'm just wondering if any one can help me with this development
issue I'm having. I've created a customized treeview control to handle the
particular tasks to which I'll be using it. Within the control I'm
dynamically creating a context menu and assigning it to the ContextMenu
property of the control -- think of this like the default context menu for
standard textboxes -- the context menu has a number of menu items that
reflect certain operations: add/edit/delete etc.
I have NO problems creating the actual menu itself, and in the test
application it displays correctly with all the items I've added to it. What
I DO have a problem with is that I cannot seem to access the events
associated with the menu like you would on normal form.
Here are some code snippets to illustrate:
DECLARATION:
Friend WithEvents __InternalContextMenu As New ContextMenu
ROUTINE TO CREATE THE MENU:
Private Sub CreateContextMenu()
Try
'add items to the context menu
With Me.__InternalContextMenu
.MenuItems.Add("Add Node Type A")
.MenuItems.Add("Add Node Type B")
.MenuItems.Add("Add Node Type C")
.MenuItems.Add("Add Node Type D")
.MenuItems.Add("-")
.MenuItems.Add("Delete Node Type A")
.MenuItems.Add("Delete Node Type B")
.MenuItems.Add("Delete Node Type C")
.MenuItems.Add("Delete Node Type D")
End With
'Set the MyTreeView ContextMenu property
'to use this default one:
Me.ContextMenu = Me.__InternalContextMenu
Catch ex As Exception
Dim ErrHandler As New ErrorLog(ex, MyAppPath())
Exit Sub
End Try
End Sub
The routine is being called from the Treeview's constructor.
QUESTION:
How do I Add event handler[s] to deal with click events on the context menu?
Any help from you pros out there would be very, very much appreciated.
--
Message posted via http://www.dotnetmonster.com