Board index » delphi » Cganging colour in a grid

Cganging colour in a grid

Hi,

I cant find a way to change the colour in a grid. What i want to do is
to change the colour of one record(Line), not of the column.

Please Help.
Thanx,
Koos Mare

 

Re:Cganging colour in a grid


What grid are you using?

--
Michael Glatz
mgl...@briefcase.com

Quote
Koos Mare wrote in message <361B1CB1.894EC...@ethniks.co.za>...
>Hi,

>I cant find a way to change the colour in a grid. What i want to do is
>to change the colour of one record(Line), not of the column.

>Please Help.
>Thanx,
>Koos Mare

Re:Cganging colour in a grid


Use the OnDrawColumnCell event as shown below.

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if Column.FieldName = 'ItemsTotal' then
    begin
    if OrdersItemsTotal.Value > 10000 then
      begin
        DBGrid1.Canvas.Font.Color := Edit1.Color;  { Font color }
        DBGrid1.Canvas.Brush.Color := Edit2.Color; { Cell color }
      end;
      DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end;
end;

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads