Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to color selected rows with Tgriddrawstate ?

1,130 views
Skip to first unread message

khng

unread,
Nov 23, 1998, 3:00:00 AM11/23/98
to
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if State = gdSelected then // this line won't work but that is what i
want
Column.Color := clBlue
else if DataCol = 2 then
Column.Color := clGreen;
end;

how do i color a selected row blue on a dbgrid which has the rowselect =
true when the user click (select) on it ?

TGridDrawState defines the possible states of a cell when drawing occurs.

Unit

Grids

type TGridDrawState = set of (gdSelected, gdFocused, gdFixed);

Description

TGridDrawState defines the possible states of cell when drawing occurs. The
TGridDrawState is the type of method parameters used for grid objects.
TGridDrawState can represent a value that includes zero or more of the
following:

Value Meaning
gdSelected The cell in the grid is selected.
gdFocused The cell in the grid has input focus.
gdFixed The cell is in the fixed (nonscrolling) region of the grid.

John Provine

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
>procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
> DataCol: Integer; Column: TColumn; State: TGridDrawState);
>begin
> if State = gdSelected then // this line won't work but that is what i
>want
> Column.Color := clBlue
> else if DataCol = 2 then
> Column.Color := clGreen;
>end;
>
>how do i color a selected row blue on a dbgrid which has the rowselect =
>true when the user click (select) on it ?
>


if State = gdSelected then

(Sender as TDbGrid).Canvas.Color := clBlue


else if DataCol = 2 then

(Sender as TDbGrid).Canvas.Color := clGreen;

This will color the background of the cells. To color the text use
"Canvas.Font".


0 new messages