* * *

Author Topic: Problem with TVirtualStringTree and alphabetical order  (Read 703 times)

pusuni

  • Jr. Member
  • **
  • Posts: 67
Problem with TVirtualStringTree and alphabetical order
« on: November 05, 2018, 12:05:28 pm »
Hi. I've wrote some code for using VirtualStringTree like a file manager. In the capture one you can see. I've define one order for file positions too: alphabetical order. That's works properly.

https://image.ibb.co/hFjeYL/Sin-t-tulo0.jpg

Now I change  the name of file. For example "Windows 10.txt" to "aWindows 10.txt" (capture two)

https://image.ibb.co/bRyj00/Sin-t-tulo1.jpg

but the new file with the new name is not in the right place. When I move the mouse out of control and i make a click in other control and now I return to the previous control, the orden in the tree changes and the file is put  in the right place (capture three) 

https://image.ibb.co/iNrRDL/Sin-t-tulo2.jpg

How can I do that immediately I press the return key? I've test witn Repaint, Refresh and invalidate but I get negative results. The tree doesn't change. How can I force a repaint of the tree nodes?


Thanks in advanced

GetMem

  • Hero Member
  • *****
  • Posts: 3210
Re: Problem with TVirtualStringTree and alphabetical order
« Reply #1 on: November 05, 2018, 12:57:28 pm »
You should sort the tree when the OnEdited event is called(editing has finished):
Code: Pascal  [Select]
  1. VirtualStringTree1.SortTree(0, sdAscending);
The above code will sort the first column in ascending order.

pusuni

  • Jr. Member
  • **
  • Posts: 67
Re: Problem with TVirtualStringTree and alphabetical order
« Reply #2 on: November 05, 2018, 01:48:07 pm »
Thanks a lot

That's fixed the issue

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus