Add Root Nodes to tree view

  • Thread starter Thread starter Mark Broadbent
  • Start date Start date
M

Mark Broadbent

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, 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.
 
Back
Top