Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2004

Tip: Looking for answers? Try searching our database.

Add Root Nodes to tree view

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Broadbent - 26 Aug 2004 17:25 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.