Board index » delphi » dbgrid wizardy : changing color of highlighted row with ...

dbgrid wizardy : changing color of highlighted row with ...

how can i chage the color of the highlighted or selected row to a different
color by turnung defaultdrawing to false and then using drawcolumncell to
change the font color of the selected row to green ?

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin

end;

Thanks a lot.

Lost.

 

Re:dbgrid wizardy : changing color of highlighted row with ...


You can do it like the next sample:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
        if Table.FieldByName( 'Type' ).Value > 0 then
           if gdSelected in State then
              (Sender as TDBGrid).Canvas.Font.Color := clYellow
             else
              (Sender as TDBGrid).Canvas.Font.Color := clBlue
          else
           if gdSelected in State then
              (Sender as TDBGrid).Canvas.Font.Color := clWhite
             else
              (Sender as TDBGrid).Canvas.Font.Color := clBlack;
        DefaultDrawColumnCell( Rect, DataCol, Column, State );
end;

khng escribi en mensaje <01be1742$ad1d1fc0$0d00a...@ngpc.dbix.com.my>...

Quote
>how can i chage the color of the highlighted or selected row to a different
>color by turnung defaultdrawing to false and then using drawcolumncell to
>change the font color of the selected row to green ?

>procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
>  DataCol: Integer; Column: TColumn; State: TGridDrawState);
>begin

>end;

>Thanks a lot.

>Lost.

Other Threads