|
-
May 30th, 2000, 10:40 AM
#1
Thread Starter
PowerPoster
Well, no gurus responded to my earlier posts regarding the TreeView questions I had, especially on how to scroll the TreeView when dragging and dropping a node. So I was forced to take matters into my own hands! After surfing for a while I found what I was looking for at:
http://support.microsoft.com/support.../Q177/7/43.asp
After applying their example to my project, it worked great.
I could still use some help on the sorting issue, although this is not as critical. (The issue was, when dropping a child node from one parent to another, how do you sort the "new child" within the new parent? I don't know quite how to apply the Sorted property.)
"It's cold gin time again ..."
Check out my website here.
-
May 30th, 2000, 10:59 AM
#2
Conquistador
you put, sorted = true
then it should automatically work for the children as well
-
May 30th, 2000, 09:41 PM
#3
Thread Starter
PowerPoster
Thanks for responding, David, but the Sorted property of the TreeView only sorts the nodes immediately below it. To sort the nodes below each of those, each of those nodes needs to have their Sorted property set to true in code. Every time a new node is added, the sorted property of the new node's parent must be reset to true.
I found that I had to do the following in the DragDrop event of the TreeView (nodSource is the Node object I'm dropping into a new parent):
Code:
With TreeView1
If Not (.DropHighlight Is Nothing) Then
Set nodSource.Parent = .DropHighlight
nodSource.Parent.Sorted = True
Set .DropHighlight = Nothing
End If
End With
Set nodSource = Nothing
"It's cold gin time again ..."
Check out my website here.
-
Dec 16th, 2001, 07:11 PM
#4
Treeview Sorting
I could also use some pointers for sorting a treeview control. For me the sorting property is worthless. I need much more advanced searches. I store my Treeview data in an Access database and I could use queries and add the nodes according to the queries, but this seems iw would be a bad use of resources.
It's not a question of not knowing how to sort them, it is more of a question of wanting to see some other examples and figure out the most efficient and non-resource hogging methods of sorting nodes in a treeview control programmatically based on any set of conditions.
I like the Treeview control because it displays data quite well. Problem is it is very hard to initially learn how to program with it. It took me a while to get it down. I actually use what I call Hierarchial Identifiers, which is basically a key that stores the relationship/position of each node to the root of the tree.
The great thing about this is, it makes your treeview code portable. You can use it in any of your programs.
I call the Hierarchial Identifier Number the HID.
I put the HID in the key property of each node.
For instance:
A0---Root Node (first node's HID = A0)
-------A0-1 (Second Hierarchy = A0-1, A0-2, A0-3, etc...)
--------- (Third Hierarchy = A0-1-1, A0-1-2, etc..)
Then for a second root branch you could do something like this.
B0 --- Root Node
-------Second Hierarchy = B0-1, etc...
This gives you an unlimited combination and instant referecing of the nodes all the way to the highest root or farthest child without having to use the slower internal methods on the treeview objects. You can parse the HID and know which root node it came from and you can easily reference these numbers in an Access database as indexed keys, primary or otherwise. To make a primary key just convert the letter part to the Ascii value and then add the Ascii value to the Number part of the HID. For instance, Asc(HIDLetters) + HIDNUMBERS = Primary Key. This gives you an instant unique number for each node object.
This does take more memory to store the keys, but you'd be surprised that it does not take as much as you might think. Also, you could convert the HID system to a mathematical equation like a single number or something, if you really wanted to save memory.
A question and my own viewpoint about the Treeview control...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|