我也来凑凑热闹,不求分数,只求共同进步
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if Column.FieldName = 'demo' then //这里假定字段为demo
begin
DBGrid1.Canvas.FillRect(Rect);
if Column.Field.AsInteger>0 then
DBGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,Column.Field.asString)
else
begin
DBGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,'该值不存在');
end;
DBGrid1.Canvas.DrawFocusRect(Rect);
end;
end;
不过这个方法不完美
显示有一圈虚框,不知哪位能解决