我手上正好有一个程序,是ondrawcolumn的,先贴出来吧
procedure TLaserMain.RefDBGridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
case DataCol of
1, 2, 3:
begin
RefDBGrid.Canvas.Brush.Color := LsrManSet.FieldTable.FieldByName(Column.FieldName).AsInteger;
RefDBGrid.Canvas.FillRect(Rect);
end
else RefDBGrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;