2006. szeptember 7., csütörtök
How to change the highlight colour in a TDBGrid
Problem/Question/Abstract:
How to change the highlight colour in a TDBGrid
Answer:
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if gdSelected in State then
DBGrid1.Canvas.Brush.Color := clLime;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;
or use the OnDrawColumnCell method like this:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
inherited;
with (Sender as TDBGrid) do
begin
if gdSelected in State then
begin
Canvas.Font.Style := [fsBold];
Canvas.Font.Color := clRed;
Canvas.Brush.Color := clYellow;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése