[Lazarus] Sorting StringGrid by column click
Jesus Reyes
jesusrmx at yahoo.com.mx
Thu May 12 21:33:50 CEST 2011
--- El jue 12-may-11, Alexander Klenin <klenin at gmail.com> escribió:
> De: Alexander Klenin <klenin at gmail.com>
> Asunto: Re: [Lazarus] Sorting StringGrid by column click
> A: "Lazarus mailing list" <lazarus at lists.lazarus.freepascal.org>
> Fecha: jueves, 12 de mayo de 2011, 7:45
> On Thu, May 12, 2011 at 23:37,
> Hans-Peter Diettrich
> <DrDiettrich1 at aol.com>
> wrote:
> > Alexander Klenin schrieb:
> >
> >> BTW, I agree with the commenter in Mantis who said
> that sorting type
> >> is a required
> >> requisite. Sorting numeric columns as strings is
> not merely useless, but
> >> subtly
> >> dangerous, since it may deceive user with
> incorrect results.
> >
> > A CustomSort method would be the way to go.
> >
>
> That is true (although, of course, it should be an event,
> not method),
> but at least numeric sort should IMHO be supported by
> default,
> since otherwise there is a high probability of user
> confusion.
>
> --
> Alexander S. Klenin
Just let's not forget that this is a generic *string* grid, why users should expect it to sort numbers when the grid is specifically made to hold strings?
Appart from strings, the grid already supports Custom Sorting, so it can sort any way the user wants, even numbers. Just write an handler for OnCompareCells, this is even documented: http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Sorting_Columns_or_Rows
Jesus Reyes A.
More information about the Lazarus
mailing list