Topic: A sorted TreeView

Hello all MVD users !

A silly question.
In a project, I'm using MVD's TreeView.
Everything works perfectly.
But how do you go about sorting the parent nodes alphabetically?
I couldn't find anything about it in the properties.of the component.
I tried Form1.Treeview1.Sorted: = True;
Nothing to do, and nothing found on the web !

This is inconvenient as I am creating a note manager for snippets gleaned (and verified) from the MVD forum and an unsorted nTreeView,
it looks messy.
Once this is done and if it works perfectly, I will make it available on the MVD forum.
Thank you for your help.

JB

2 (edited by derek 2020-12-25 22:01:33)

Re: A sorted TreeView

Salut Jean et Joyeux Noël
I did a small project with treeview sorting a couple of years ago - perhaps the attached can give you some ideas?
At the time of writing it, it was the only way I could think of sorting a treeview (in the example there are 2 sort levels - aircraft sorted within manufacturer).
What I do is sort the treeview in real time (because the amounts of data weren't large).  But if you have a lot of data this might take a few seconds;  If so you can make the 're-sort' button visible and do it manually.
There was also a problem with some records not being assigned an ID so I had to trap that as well;  I never did find out why it was happening but I don't think it was anything to do with my sort routine (but it was quite a while ago so I don't remember all the details)..
Anyway, here you go and I hope this helps,
Derek.

Post's attachments

Attachment icon sorted treeview.zip 338.01 kb, 284 downloads since 2020-12-25 

Re: A sorted TreeView

Hello Derek
Thank you for your prompt response
Your script does the job impeccably.
It is strange that this routine is not incorporated by default in the management of the TreeView.
After all it is a classic grid in which alphabetical sorting could be done in a dark spot.
Thanks again.
And Merry Christmas (one day late) and Happy New Year (as well as to all MVD users and to Dmitry).
Protect everyone well from this horrible virus.
JB