Link to home
Start Free TrialLog in
Avatar of David Glover
David GloverFlag for United Kingdom of Great Britain and Northern Ireland

asked on

.NET VB - Class - How to create a tree with navigation methods?

I have been trying to create a tree structure similar to that of a treeview but with proprietary methods and properties.
I have seen a number of examples on how to do a binary tree but I am looking for something closer to a regular tree i.e many nodes of each branch, each possibly having many more nodes and so on.
Performance isn't that crucial since the trees will in most cases have less than 10 nodes.
Apart from methods to add new nodes, count and index (as seen in collectionbases), I could do with each node having parentnode,lastchild,firstchild properties and a means of finding a node anywhere in the tree and a means of listing all nodes whatever level they are at.  I see that XML also accommodates these kinds of routines although I wanted something more strongly typed and that would allow derived classes of a base class to exist as the nodes.
I realise this is quite a broad question and it would be expecting a lot from an expert to conjure something up as an answer but perhaps somebody out there has already seen or used a structure that would support this and can suggest or point to similar examples.
I am only competent in VB but I can always try and convert a c# solution using online converters if these are the only examples available.
Thank you in advance!
Avatar of plusone3055
plusone3055
Flag of United States of America image

There are thousands (literally) of examples out there in both VB.NET and C#
start with a step by step video  here
https://www.youtube.com/watch?v=psyIyq0910I

also there are several already completed packaged trees that you require..
I cannot post direct links to them as that would violate EE policy.

I can however suggest that you enter the following in google
Vb.net create tree with navigation
Avatar of David Glover

ASKER

Sorry I realise my question didn't make it very clear but I wanted an object oriented solution using inheritance, probably collectionbases and recursive methods.  I am not interested in the treeview control or other controls although these controls are built upon the same class structure I am trying to re-create.  I have tried googling myself and have not found any examples much less thousands although this is partly down to the problem of hitting articles about the tree view control.
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you Ark, that first example looks the best, I will have to see about trying to convert it to VB since I want to create new properties for each node.