removing sort indicator in TStringGrid lazarus / 31-LCL ---------------------------------------------------------------------- inferno · 2020-02-18 23:10 Hi all, I use TStringGrid with allowed columns sorting and row moving (macOS Mojave 10.14.6 + Cocoa). When some column is first sorted and then the rows are moved, the column has no right order and the sorting indicator (default green arrows or some icons when used TitleImageList, ImageIndexSortAsc and ImageIndexSortDesc) should be removed. Have no idea to to do this. Assigning StringGrid.Columns.Title.ImageIndex:=-1; doesn't work - this value is equal -1 for all columns including the sorted one. Any suggestions? Best regards, Inferno ---------------------------------------------------------------------- GAN · 2020-02-18 23:55 Recently discussed in this thread: https://forum.lazarus.freepascal.org/index.php/topic,48340.0.html ---------------------------------------------------------------------- inferno · 2020-02-19 00:25 GAN, Thank you for the suggestion, but I found this thread before posting and unfortunately this is not a solution in my case. As I mentioned, assigning StringGrid.Columns.Title.ImageIndex:=-1 doesn't work at all. Another sugestion TStringGrid.ColumnClickSort := False is a solution only when you want to completely disable sorting. My case is different: columns sorting is allowed, but sometimes user can disturb the order by row moving (also allowed by goRowMoving:=true). In this case sorting icon should be hidden because column is no longer sorted. But when user after moving rows again click in some column header, sorting should be activated and sort indicator should be displayed again according to sort order. In other words, I need a solution to temporary hide sort indicator until next sort task. Best regards, Inferno ---------------------------------------------------------------------- winni · 2020-02-19 00:31 Hi! Do the drawing of the cells on your own: Set DefaultDrawing to false. Create OnDrawCell. No you can draw in row zero every icon you like. But you must keep track of it. Winni ---------------------------------------------------------------------- wp · 2020-02-19 06:24 I added a public method "HideSortArrow" in r62644. If you do not use Lazarus trunk you can patch your current version easily: Open file grids.pp from folder lcl of your Lazarus installationIn the interface part of the unit find the public declarations of TCustomGrid and add the lineCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure HideSortArrow;In the implementation part add this code (I put it after the TCustomGrid.Sort method):Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomGrid.HideSortArrow;begin  FSortColumn := -1;  InvalidateGrid;end; In principle this method should be called whenever rows are rearranged in a sorted grid. The place where this should happen is procedure ColRowModed, but I am not 100% sure if this has any side-effects. Therefore, you must call HideSortArrow yourself in the OnColRowMoved method. ---------------------------------------------------------------------- inferno · 2020-02-20 00:13 Thank you for suggestions! It looks the solution with adding HideSortArrow to TCustomGrid works well, no side-effects until now. But I hope it will be implemented directly in TCustomGrid as there are many cases where sorting order can be changed. It is definitely something that was missed during sorting implementation. Best regards, Inferno ---------------------------------------------------------------------- wp · 2020-02-23 12:02 I now changed the grid's internal method DoOPMoveColRow to remove the sort arrow when a row is moved in a column-sorted grid without user code. I think it works correctly, but please test yourself and report back. To implement the change in a non-trunk Lazarus version do this: Load grids.pas (from folder "lcl" of your Lazarus installation)Find procedure TCustomGrid.DoOPMoveColRowNear the end, there is an "if" block with the comment "// adjust sorted column"Add an "else" block with "FSortColumn := -1". The entire "if" block should be like this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // adjust sorted column  if IsColumn and (FSortColumn>=0) then begin       // "begin" added    if Between(FSortColumn, FromIndex, ToIndex) then begin         if FSortColumn=FromIndex then        FSortColumn := ToIndex      else      if FromIndex