Nasty TreeViews

cBarry263

Active member
Joined
Oct 29, 2005
Messages
42
Location
Maryland
Programming Experience
Beginner
Guys,
A friend of mine is working on a program and we are trying to do something kind of unique, in that I have found nothing on the web about this so far.
We have a treeview of say 100 nodes. Each of these nodes corresponds to an image. We want the user to enter a "page" number (in the form of an int) and have that node become the selected node, therefore displaying the associated image. Anyone have any ideas how to acheive this functionality?
 
Are these nodes arranged in a tree structure or are they all root nodes? If they're all root nodes then why use a TreeView at all? Just use a ListView instead. If they are in a tree structure then you have a couple of options. Firstly though, you have to decide what the index means. Are your nodes numbered by order of depth, i.e. all root nodes are numbered first, then all first level nodes and so on, or are they numbered by order of parent, i.e. the first first-level node is numbered first, then its first child, then its first child and son until you reach a leaf, then you start numbering second children. Then you have two choices. You can just start traversing the tree in the manner you previously decidied that nodes would be numbered in and just keep counting until you get to the desired index, or you can store the node index in its Tag property and test each one until you find the desired value. Using the Tag is not a good idea if you intend to add and remove nodes along the way.
 
Let me Quote...

"Dear John,
The guy pointed out that he is trying to make something unique"


Seems making a demo that solves the problem isn't quite 'fair' either...
 
He's using a TreeView. How is that any more unique than a ListView? Isn't finding the best solution to the problem the most desirable outcome? Someone may think that their situation is unique because, as stated, they haven't found anything on the Web that seems to relate, but maybe they were searching for the wrong thing. I suggested a ListView as a possible solution for a certain set of circumstances. I also suggested other solutions for other circumstances. If any of them work that's great, but if they don't for whatever reason then we can keep trying. The last line reads "Anyone have any ideas how to acheive this functionality?" and a ListView would do just that if there is no actual tree structure to the nodes.
 
Back
Top