[Lazarus] Sorting StringGrid by column click
Alexander Klenin
klenin at gmail.com
Mon May 9 12:51:33 CEST 2011
On Mon, May 9, 2011 at 19:51, Juha (gmail) <juha.manninen62 at gmail.com> wrote:
> I almost always want my StringGrids to sort automatically when user clicks a
> column title.
> So, I implemeted such feature as property ColumnClickSorts (r30630 + some
> others for images).
> Jesus Reyes and others, please test.
>
> Some notes:
> - I created sort glyph images using my artistic skills and Gimp...
> ... ok, I just rotated an existing image 90 decrees.
> I would be happy if someone creates / finds better images.
>
> - ImageList is created "on the fly" if not set by user.
> The sort glyphs and loaded dynamically in any case.
> The only potential error comes when user first clicks the columns, ImageList
> gets created, and later user's code assigns another ImageList. It wouldn't
> crash but wrong images would be shown. I think this is very rare and can
> easily be avoided, so it is not a real problem.
When I implemented title images a few years ago, I did it exactly it to allow
column sorting indicators.
However, I stopped before hard-coding sorting images into the StringGrid
because I did not see an elegant way to do it -- in other words, I specifically
wanted to avoid your kind of implementation.
Perhaps I was wrong -- a crude functionality is better than none,
just wanted you to know.
> - Sorting works for all columns but the glyphs are shown only for persistent,
> user defined columns. It is so by definition. If you want to see images you must
> define columns.
See http://bugs.freepascal.org/view.php?id=12823
> - Column.Title.ImageIndex is now -1 by default. Value 0 as default is wrong
> because it is a valid list index.
Agreed, it was a mistake.
--
Alexander S. Klenin
More information about the Lazarus
mailing list