delphi dbgrid row color change

Set dgRowSelect to True, in option.


// OnDrawColumnCell event of DBGrid1


if ((State = [gdSelected]) or (State=[gdSelected,gdFocused])) then
    begin
      DBGrid1.Canvas.Font.Color :=ClYellow;
      DBGrid1 .Canvas.Brush.Color :=clblue; //Key
      DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
 end;
DBGrid1.Canvas.Font.Color :=ClYellow;//Font color, you can change it to what you want DBGrid1.Canvas.Brush.Color :=clblue; //The background color can be changed to what you want

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325495201&siteId=291194637