TVirtualTreeview sorting issue

223 Views Asked by At

I have a TVirtualTreeview in my application (still D2007 based) which sets RootNodeCount to the desired value and in OnInitNode event I assign an Object to the node which is otherwise being stored in a TObjectList in my busines logic class. The object is taken from the business logic class by the Nopde's ID which acts as index into the TObjectList.

Now I added sorting capabilities to the VST which for instance meant to add a comparison method to my business logic class which takes the objects attached to the two nodes the OnCompareNodes event gets passed. So far so good, the VST itsself sorts.

Since I'd like the business logic to have the same sorting as that can print or export data and it should do so in the same way it is being displayed I thought I'd use the TObjectList's .exchange method and simply give it the ID's of the two nodes passed to OnCompareNodes.

That fails. The output I get and the debugger supports this is quite different. I'm quite puzzled about the possible reasons. of course I could implement sorting of the TObjectList in my business logic class separately and apply this at the end of the OnHeaderClick event, but that's some additional effort I'd like to avoid.

Any ideas about what I might do wrong or where I'm wrong?

1

There are 1 best solutions below

0
On

Ok, the answer is that the business logic manages everything and the VST in GetText etc. gets the required data directly from the bussines logic via the Node.Index. Then business logic can do the sorting as it likes.