E
Eric Newton
Easy part is creating a context menu for a specific node
(one of several examples follows)
Private Sub treeview_MouseUp(byval sender as object, byval e as
MouseEventArgs) handles TreeView1.MouseUp
if e.Button = MouseButtons.Right then
Dim node as TreeNode = TreeView1.GetNodeAt(e.X,e.Y)
if not node is nothing then
if typeof node is TYPE1 then
ShowContextMenu(BuildContextMenu(DirectCast(node.Tag,TYPE1)))
elseif typeof node is TYPE2 then
ShowContextMenu(BuildContextMenu(DirectCast(node.Tag,TYPE2)))
'... and so on ...
end if
end if
end if
end if
NOW Heres the problem:
Once a menu item is clicked, how does one accurately get the node that
triggered the whole set of operations?
Answer is, you cant... since MenuItems dont have TAGS you cannot associate
Clicks events with actual data.
A serious flaw in the MenuItem class in my opinion
(one of several examples follows)
Private Sub treeview_MouseUp(byval sender as object, byval e as
MouseEventArgs) handles TreeView1.MouseUp
if e.Button = MouseButtons.Right then
Dim node as TreeNode = TreeView1.GetNodeAt(e.X,e.Y)
if not node is nothing then
if typeof node is TYPE1 then
ShowContextMenu(BuildContextMenu(DirectCast(node.Tag,TYPE1)))
elseif typeof node is TYPE2 then
ShowContextMenu(BuildContextMenu(DirectCast(node.Tag,TYPE2)))
'... and so on ...
end if
end if
end if
end if
NOW Heres the problem:
Once a menu item is clicked, how does one accurately get the node that
triggered the whole set of operations?
Answer is, you cant... since MenuItems dont have TAGS you cannot associate
Clicks events with actual data.
A serious flaw in the MenuItem class in my opinion