E
Eric Newton
I'm working on a project with a couple of TreeView controls and I've
realized that once you desire true node-context-menus that its incredibly
difficult to achieve...
For instance, I first tried to tie into the AfterSelect event, which has a
reference to the newly selected node as part of the Event args passed in,
however... its actually too LATE for a context menu to be displayed!
So, I began to think about "how would I want treenodes to be" and I came up
with this:
A) TreeNodeEx, inheriting from TreeNode [System.Windows.Forms namespace], so
that you can add these TreeNodeEx instances to a normal TreeView
B) the TreeNode itself has a ContextMenu property that will be displayed
when the TreeView gets a right mouse click and the node"EX" has ContextMenu
set... [Anybody have a suggestion on how to specify that maybe the
contextmenu should show up via Left mouse instead of the normal right
click?]
C) the TreeNode has BeforeExpand event delegates, which gives you the
ability to make the node "seem" like it has some children, but no processing
for the children takes place until the node itself is expanded... reason for
this is so that a process that might be expensive can be deferred to when
the Node itself wants to be expanded... a great example of this is the
Windows Explorer Folder treeview... each subfolder node's children arent
actually created until you expand the parent's node... saves a lot of time
having to traverse deep directory trees that you most likely dont even care
about...
Anyhow, I'll be posting progress on my website soon [its being moved to a
different hosting location]
realized that once you desire true node-context-menus that its incredibly
difficult to achieve...
For instance, I first tried to tie into the AfterSelect event, which has a
reference to the newly selected node as part of the Event args passed in,
however... its actually too LATE for a context menu to be displayed!
So, I began to think about "how would I want treenodes to be" and I came up
with this:
A) TreeNodeEx, inheriting from TreeNode [System.Windows.Forms namespace], so
that you can add these TreeNodeEx instances to a normal TreeView
B) the TreeNode itself has a ContextMenu property that will be displayed
when the TreeView gets a right mouse click and the node"EX" has ContextMenu
set... [Anybody have a suggestion on how to specify that maybe the
contextmenu should show up via Left mouse instead of the normal right
click?]
C) the TreeNode has BeforeExpand event delegates, which gives you the
ability to make the node "seem" like it has some children, but no processing
for the children takes place until the node itself is expanded... reason for
this is so that a process that might be expensive can be deferred to when
the Node itself wants to be expanded... a great example of this is the
Windows Explorer Folder treeview... each subfolder node's children arent
actually created until you expand the parent's node... saves a lot of time
having to traverse deep directory trees that you most likely dont even care
about...
Anyhow, I'll be posting progress on my website soon [its being moved to a
different hosting location]