marmaxx
asked on
Sorting a TreeViewControl
I need to sort a TreeView control based on one of two selected user options. The problem is, that the Text property of my TreeView nodes is set to a string that is actually a cocatenation of two database fields. For example, I am retrieving the followng values from my database: UserID, UserName, and displaying them in my TreeView like this: UserID - UserName.
I need to be able to sort by either of these fields.
I have looked at the TreeViewNodeSorter property, but haven't been able to figure out how to 'tweak' it to meet my needs.
Has anyone here done something similar?
Thanks!!
I need to be able to sort by either of these fields.
I have looked at the TreeViewNodeSorter property, but haven't been able to figure out how to 'tweak' it to meet my needs.
Has anyone here done something similar?
Thanks!!
if I remember correctly, the treeview nodes/items have a property that can hold an object of any type (the type of that property is Object) you can create a wrapper class that will hold the 2 fields and set that treeview node's "object" property. then, in the custom sort event (delegate) you compare using that object from the node casted to the wrapper which will give you the 2 fields.
ASKER
I believe we're talking about the same property - TreeViewListSorter. I tried your suggestion, but I'm still not having any luck. Would you be willing to post a small snippet, so that I can get a better idea of what you're taling about?
Thanks again for the feedback. I appreciate it.
Thanks again for the feedback. I appreciate it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You!
I may have to tweak it a bit, but I get the idea. This should work for me.
I'm going to go ahead and award the points now since I'm sure I can use this.
I really appreciate you taking the time to provide the snippet.
I may have to tweak it a bit, but I get the idea. This should work for me.
I'm going to go ahead and award the points now since I'm sure I can use this.
I really appreciate you taking the time to provide the snippet.
glad to help :)