DjDMac
asked on
2 TreeViews & problem.. selecting same treenode from both..
I have 2 treeviews. Both treeviews has exactly the same structure.
If i select one node from view 1, how can i retrieve the text of same node of view 2 ?
View 1 will be visible and view 2 hidden, just for filenames..
If i select one node from view 1, how can i retrieve the text of same node of view 2 ?
View 1 will be visible and view 2 hidden, just for filenames..
I agree with Mike's ending comment - this is what the data property exists for - invisible data that the node references. Data is a generic pointer type, just build a string, and point data at it. If you need a structure, put all the strings into a string list, and have each pointer point to the item in the stringlist as you build it.
ASKER
Ok.. so i can use the data property, but how can i save the data propertys to file ?
Example.. i have message topics in treeview.. messages with replys etc.
Then i have each message in simple text file. now i need to store each messages filename to the treeviews nodes data property and save and also load this whole treeview including those data-propertys.. how can i do this ?
Example.. i have message topics in treeview.. messages with replys etc.
Then i have each message in simple text file. now i need to store each messages filename to the treeviews nodes data property and save and also load this whole treeview including those data-propertys.. how can i do this ?
I see what you're getting at, but I think I can see an easy solution. Going back to the stringlist idea I gave, try this:
At save time, you must make sure that for a given order of the treeview, your stringlist is sorted the same. Traverse the tree, and make sure that the root of the treelist is index[0] in the stringlist, the first item of the first node is [1], etc. Then just do a Stringlist.savetofile.
At load time, just load the tree and the stringlist from the file, and traverse the tree in a for loop from 0, setting the data component to StringList.items[loopindex ] for each node.
At save time, you must make sure that for a given order of the treeview, your stringlist is sorted the same. Traverse the tree, and make sure that the root of the treelist is index[0] in the stringlist, the first item of the first node is [1], etc. Then just do a Stringlist.savetofile.
At load time, just load the tree and the stringlist from the file, and traverse the tree in a for loop from 0, setting the data component to StringList.items[loopindex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is really the simplest answer..
However, I re-coded the whole program, but thanx anyway.. I like short and simple answers..
However, I re-coded the whole program, but thanx anyway.. I like short and simple answers..
Oh, thanks for the nice surprise, 400 pts, yay! ;-)
Cheers,
Phil.
Cheers,
Phil.
A better solution, though, would be to store references between the trees in the nodes' data property. This mean node1 of tree one stores node1 of tree2 in its data property and vice versa. As both trees have the same structure I suppose you build them synchroniously. So crossreferencing the nodes is only a minimal additional step.
You should ask yourself, though, why you need two trees of the same structure! They are equal, so you could store them in one tree.
Ciao, Mike