procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin //ne colorie pas la cellule détenant la focalisation if not (gdFocused in State) then begin //colorie ce qui correspond à la première //colonne if Column.Index = 0 then //couleur selon une valeur déterminée par le contenu //du champ SpeciesNo if Table1SpeciesNo.AsInteger < 90100 then begin Column.Color := clGreen; Column.Font.Color := clYellow; end else begin Column.Color := clYellow; Column.Font.Color := clGreen; end; end;
procedure TForm1.FormCreate(Sender: TObject); begin //Elimine le scintillement de DbGrid1 DbGrid1.DoubleBuffered := True; end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if not (gdFocused in State) then begin if Column.Index = 0 then with DbGrid1 do begin if TField(Column.Field).AsInteger <= 90100 then begin Canvas.Brush.Color := clGreen; Canvas.Font.Color := clYellow; end else begin Canvas.Brush.Color := clYellow; Canvas.Font.Color := clGreen; end; DefaultDrawColumnCell(Rect, DataCol, Column, State); end; end; end;