Recent

Author Topic: TStringGrid ColumnClickSort - how to 'unsort' ?  (Read 2319 times)

FrankBKK

  • New Member
  • *
  • Posts: 29
TStringGrid ColumnClickSort - how to 'unsort' ?
« on: June 15, 2021, 09:33:23 am »
TStringGrid allows to change the sorting of a column via ColumnClickSort when clicking on the Header, click again to switch Asc/Desc sort order.

How can I get back the original, unsorted view ?






Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: TStringGrid ColumnClickSort - how to 'unsort' ?
« Reply #1 on: June 15, 2021, 09:42:11 am »
You can't.
Except if you saved the "original" sort somewhere
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

FrankBKK

  • New Member
  • *
  • Posts: 29
Re: TStringGrid ColumnClickSort - how to 'unsort' ?
« Reply #2 on: June 15, 2021, 07:24:13 pm »
Thanks for the quick reply - that's bad though ....

What is the best approach to circumvent this ?

A secondary backup grid to restore the original sort order seems like overkill and to add an add. sort column is something I try to avoid - are there any other options ?

Awkward

  • Full Member
  • ***
  • Posts: 133
Re: TStringGrid ColumnClickSort - how to 'unsort' ?
« Reply #3 on: June 15, 2021, 07:39:20 pm »
why not to add hidden column with numbers for original order and sort by it when needs?

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: TStringGrid ColumnClickSort - how to 'unsort' ?
« Reply #4 on: June 15, 2021, 09:56:57 pm »
IIRC, the row-Property (or was it rows?) is of type TStrings, so a TStringList could/should work
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018