Delphi 有关Dbgrideh控件:变色处理
procedure OnDrawColumnCell(
Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
var
d : TDBGridEh;
begin
inherited;
if adoWorkStatioin.FieldByName('FGROUP_ID').AsString <> '' then //进行判断那些数据需要变色
begin
if adoWorkStatioin.FieldByName('FGROUP_ID').AsString = sSerTemp then
dbgWorkStatioin.Canvas.Brush.Color := clRed
else
dbgWorkStatioin.Canvas.Brush.Color := clGreen;
end;
dbgWorkStatioin.DefaultDrawColumnCell(Rect, DataCol, Column, State);//这句是让后面自动刷新变色,如没有此句将会不进行变色处理。
end;