[Lazarus] Sorting StringGrid by column click

Juha (gmail) juha.manninen62 at gmail.com
Mon May 9 13:11:47 CEST 2011


Alexander Klenin kirjoitti maanantai, 9. toukokuuta 2011 13:51:33:
> > - 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.

Hmmm...
IMO this implementation is rather elegant. How else would you do it? You could 
maintain 2 ImageList references and then guess which one to use but it is not 
better.
Typically if a user enables the automatic sorting feature, he doesn't need to 
assign his own ImageList.
But, maybe there should be 2 separate settings for automatic sorting and for 
showing glyps. Don't 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

That would indeed improve things. I added a note to the issue.


Regards,
Juha




More information about the Lazarus mailing list