Linhas coloridas numa Grid
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
Neste tem um campo de DIAS.
Há como colocar a linha da Grid dependendo do valor do campo DIAS
Uso delphi 7
Obrigado
Jonnymarques
Curtidas 0
Respostas
Fabio.hc
03/03/2004
Tente assim:
Ex:
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;
GOSTEI 0
Jonnymarques
03/03/2004
Cara funcionou que foi uma beleza.
Mas tentei fazer a linha ficar toda colorida e não consegui.
Tem alguma idéia.
Obrigado
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;
GOSTEI 0
Fabio.hc
03/03/2004
Tente assim:
Ex: [b:37cf5360de]DrawDataCell[/b:37cf5360de]
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;
GOSTEI 0