Fórum Linhas coloridas numa Grid #217906

03/03/2004

0

Tenho uma Grid vinculada a uma Query.
Neste tem um campo de DIAS.
Há como colocar a linha da Grid dependendo do valor do campo DIAS
Uso delphi 7

Obrigado


Jonnymarques

Jonnymarques

Responder

Posts

03/03/2004

Fabio.hc

Tente assim:

Ex:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
   if (Column.Field.FieldName = ´DIAS´) then
      begin
      if Column.Field.Value = 3 then 
         begin
         DBGrid1.Canvas.Brush.Color:= clAqua;
         DBGrid1.Canvas.Font.Color:= clWindowText;
         DBGrid1.Canvas.FillRect(Rect);
         DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
         end;
      end;
end;



Responder

Gostei + 0

03/03/2004

Jonnymarques

Cara funcionou que foi uma beleza.
Mas tentei fazer a linha ficar toda colorida e não consegui.
Tem alguma idéia.
Obrigado

Tente assim: Ex:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
   if (Column.Field.FieldName = ´DIAS´) then
      begin
      if Column.Field.Value = 3 then 
         begin
         DBGrid1.Canvas.Brush.Color:= clAqua;
         DBGrid1.Canvas.Font.Color:= clWindowText;
         DBGrid1.Canvas.FillRect(Rect);
         DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
         end;
      end;
end;



Responder

Gostei + 0

03/03/2004

Fabio.hc

Tente assim:

Ex: [b:37cf5360de]DrawDataCell[/b:37cf5360de]
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
   if Query1DIAS.Value = 3 then
      begin
      DBGrid1.Canvas.Brush.Color:= clAqua;
      DBGrid1.Canvas.Font.Color:= clWindowText;
      DBGrid1.Canvas.FillRect(Rect);
      DBGrid1.Canvas.TextOut(Rect.Left+2, Rect.Top+2, Field.Text);
      end;
end;



Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar