sDBGrid selected row color

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #68159
    chemirikmohamed
    Participant

    hi everyone, i would like to know how to change the color of a selected row, reverse the color of the line select. thank you

    #68163
    Support
    Keymaster

    Hello
    You can use in the OnGetCellParams event something like this:

    uses sConst;
    
    procedure TForm1.DBGrid1GetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; State: TGridDrawState; StateEx: TGridDrawStateEx);
    var
      TmpCol: TsColor;
    begin
      if geHighlight in StateEx then begin
        TmpCol.C := DBGrid1.Color;
        TmpCol.R := 255 - TmpCol.R;
        TmpCol.G := 255 - TmpCol.G;
        TmpCol.B := 255 - TmpCol.B;
        Background := TmpCol.C;
    
        TmpCol.C := DBGrid1.Font.Color;
        TmpCol.R := 255 - TmpCol.R;
        TmpCol.G := 255 - TmpCol.G;
        TmpCol.B := 255 - TmpCol.B;
        AFont.Color := TmpCol.C;
      end
    end
    
    #68190
    chemirikmohamed
    Participant

    It works well but was not obvious with the use of different skins, I would like to the selection to have bright colors especially I use in GetCellParam slEditGreen, slEditGreenText, slEditRed, slEditRedText, slEditYellow, slEditYellowText

    #68191
    chemirikmohamed
    Participant

    Thank you very much it works well, it was just necessary to put the code that you gave me after the colors proposed in GetCellParam.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘sDBGrid selected row color’ is closed to new replies.