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 / September 2004

Tip: Looking for answers? Try searching our database.

TreeView - node indexing like an Array?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arkion - 13 Sep 2004 20:20 GMT
Hello all!
Is there any way to refer to nodes in a TreeView's hierarchial
TreeNode structure by numeric indexes like with a simple Array?

I need to associate indexes with each node and be able to lookup nodes
using that index. Is there easier way to do this than recursively
iterating through the whole tree structure, looking for particular
index?
Herfried K. Wagner [MVP] - 13 Sep 2004 20:32 GMT
* Arkion <nospam@nowhere.com> scripsit:
> Is there any way to refer to nodes in a TreeView's hierarchial
> TreeNode structure by numeric indexes like with a simple Array?
[quoted text clipped - 3 lines]
> iterating through the whole tree structure, looking for particular
> index?

You can add all your nodes to a datastructure like an 'ArrayList' to be
able to perform lookup of nodes by an index.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

Arkion - 14 Sep 2004 17:17 GMT
>You can add all your nodes to a datastructure like an 'ArrayList' to be
>able to perform lookup of nodes by an index.

I need to display this data structure in a TreeView control because of
it's hierarchial nature. How do you make TreeView do this, given each
node struct contains parent index and list of child indices? I also
need to be able to delete and add new nodes to the structure. This'll
make keeping indices in sync very tricky.

With Model-View-Controller separation this prolly would be a piece of
cake, but MVC concept isn't used in WinForms.
"Jeffrey Tan[MSFT]" - 15 Sep 2004 03:13 GMT
Hi Arkion,

Thanks for your feedback.

I think this is somewhat data structure issue, why not just use the Data
Structure of treenode? We may use TreeNode.Nodes property to loop through
one node's child node collection, also its Parent property gives us a
chance to refer its parent node. I think it will be difficult to write a
recusive program to loop through all the nodes in a treeview.

Also, if you have specified a index for each node, and you may store all
the treenodes' reference in a collection, such as ArrayList, then you can
use the index to find certain node's reference, which will save some
performance(Only when you have many treenodes).

If I did not catch your concern, please feel free to tell me.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

"Jeffrey Tan[MSFT]" - 17 Sep 2004 02:29 GMT
Hi Arkion,

Does my reply make sense to you? Is your problem resolved? Please feel free
to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Rate this thread:







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.