[SOLVED] StringGrid colored rows do not change color when being selected lazarus / 31-LCL ---------------------------------------------------------------------- Vodnik · 2024-12-02 21:42 I have a StringGrid where some rows are colored different. I use the following procedure for that: 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 TForm1.StringGridPrepareCanvas(Sender: TObject; aCol, aRow: Integer;  aState: TGridDrawState);var  MyTextStyle: TTextStyle;begin  with (Sender as TMyStringGrid) do begin    MyTextStyle := Canvas.TextStyle;    MyTextStyle.SingleLine := false;    // wrap long line in cell    MyTextStyle.Wordbreak := True;    // break line in cell if linebreak found    MyTextStyle.Layout:=tlTop;    Canvas.TextStyle := MyTextStyle;    if AR[Tag].RowAttr[aRow] then begin      Canvas.Brush.Color:=$F1F1F1;      Canvas.Font.Color:=$000000;    end;  end;end; This works fine, except that rows with color set to gray do not change color when they are selected (blue). What have I missed? ---------------------------------------------------------------------- wp · 2024-12-02 22:21 You did not check the selected state: 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 ...if (gdSelected in aState) thenbegin  Canvas.Brush.Color := clHighlight;  Canvas.Font.Color := clHighlightText;end elseif AR[Tag].RowAttr[aRow] thenbegin  ... ---------------------------------------------------------------------- Vodnik · 2024-12-03 07:26 Thanks, WP! Now works fine.