在数据集的字段的OnGetText事件实现。 或者你用自画也行。 procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin with DBGrid1.Canvas do Case Column.Index of // 列号 0, 1, 2 : begin if 第四列的值为(wer) then begin DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end else begin FillRect(Rect); TextOut(Rect.Left+2, Rect.Top+2, ''); end end else DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;
或者你用自画也行。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with DBGrid1.Canvas do
Case Column.Index of // 列号
0, 1, 2 :
begin
if 第四列的值为(wer) then
begin
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end
else
begin
FillRect(Rect);
TextOut(Rect.Left+2, Rect.Top+2, '');
end
end
else
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;