Ive got an app with a treeview and to add a new node I have a context menu.
My code will add a new node as a child of the currently selected node.
If no node is currently selected (or the tree is empty) then a root node is
created to the treeview otherwise it is created as a child to the current
selected node. ...Simple yes!!
Unfortunately when one node has been created to the treeview it is
impossible to get this to add nodes to the root because the TreeViewList
seems to require one node is selected when there are nodes in the
collection. After creating the a new node I am setting the
TreeViewList.SelectedNode=null but this seems to be reset to the currently
selected node.
Apart from having an option to create a root node (which quite frankly will
be a bit naff) is there any way around this?
Br,
Mark.
Sijin Joseph - 27 Aug 2004 12:00 GMT
In the MouseUp event or whenever you are showing the ContextMenu us the
TreeView.GetNodeAt() method to determine which node is under the mouse,
if there is no node then create a root node otherwise create a child of
that node.
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> Ive got an app with a treeview and to add a new node I have a context menu.
> My code will add a new node as a child of the currently selected node.
[quoted text clipped - 15 lines]
>
> Mark.
Jediah L. - 28 Aug 2004 02:36 GMT
Mark,
There is a great article located here that describes what Sijin is
suggesting:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;811399
Good Luck!
> In the MouseUp event or whenever you are showing the ContextMenu us the
> TreeView.GetNodeAt() method to determine which node is under the mouse, if
[quoted text clipped - 28 lines]
>>
>> Mark.
Mark Broadbent - 31 Aug 2004 14:49 GMT
Sijin, Jediah thx.
That will work and I guess it is the best workaround. It is a shame that
TreeView is not a little more flexible though because logically my code
should have worked. Nevermind... thanks for your suggestion.
Br,
Mark.
> Ive got an app with a treeview and to add a new node I have a context menu.
> My code will add a new node as a child of the currently selected node.
[quoted text clipped - 15 lines]
>
> Mark.