Recent

Author Topic: TStringGrid TitleImageList and ColumnClickSort  (Read 1821 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
TStringGrid TitleImageList and ColumnClickSort
« on: January 30, 2020, 03:57:18 pm »
Dear all,
I noticed a minor issue that make lazarus on cocoa behaves differently from windows and linux.
If I set
TStringGrid.ColumnClickSort := True
and I define a TitleImageList and the corresponding OnHeaderClick event, when I click on a Column header two images are shown on the header. Both the lazarus default icon and my images in TitleImageList (see attached image).
While on Windows only one image is shown.

See attached example project.

 



wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TStringGrid TitleImageList and ColumnClickSort
« Reply #1 on: February 20, 2020, 01:28:12 am »
For me, Windows also shows two icons. What is your Lazarus version? There has been some work with the grid title images some time ago.

Showing two icons is correct. Because the TitleImages, per se, are not thought for sorting indicators but for decorative purposes, like button images or so.

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: TStringGrid TitleImageList and ColumnClickSort
« Reply #2 on: February 20, 2020, 08:50:13 am »
I am using lazarus 1.8.4 on windows and linux and Lazarus 2.0.7 r62622M FPC 3.0.4 x86_64-darwin-cocoa (alpha) on mac.
So, there is no way to use:
TStringGrid.ColumnClickSort := True
and my own sort images?

Anyway I can deal with it.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: TStringGrid TitleImageList and ColumnClickSort
« Reply #3 on: February 20, 2020, 06:07:42 pm »
So, there is no way to use:
TStringGrid.ColumnClickSort := True
and my own sort images?

It was not clear that you want to replace the built-in sort arrows by your own icons. You are lucky: The grids have properties ImageIndexSortAsc and ImageIndexSortDesc which you can use to override the images. These indexes point into the TitleImageList. Additionally you can still have the normal title icons defined by Column.Title.ImageIndex. This way the sorted column can display two icons. The column icon can be positioned to the left/right/above/below the caption by using the column.Title.ImageLayout property while the sort icon is always at the right. Of course, when Column.Title.ImageIndex is left at -1 then the sorted column is decorated only by the sort icon.
« Last Edit: February 20, 2020, 06:30:06 pm by wp »

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: TStringGrid TitleImageList and ColumnClickSort
« Reply #4 on: February 21, 2020, 08:18:55 am »
Ok, thank you for all the info.

 

TinyPortal © 2005-2018