第2个问题好解决:
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if field.IsNull then
begin
DBGrid1.Canvas.Brush.Color:=clGray;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.font.color:=clBlack;
DBGrid1.Canvas.Textout(Field.asstring);
end
else
DBGrid1.DefaultDrawDataCell(Rect,field,state);
end;
第1,第3,什么意思????????????????
to eyes4:
>>if field.IsNull then
>> begin
>>……
DBGrid1.Canvas.Textout(Field.asstring);
>>……
Field.IsNull为True的话,Field.AsString岂不是为空?用TextOut还有意义吗?
估计lianzj不是这个意思吧。不过俺确实没看懂什么意思
if field.IsNull then
begin
DBGrid1.Canvas.Brush.Color:=clGray;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.font.color:=clBlack;
DBGrid1.Canvas.Textout(Field.asstring);
end
else
begin
DBGrid1.Canvas.Brush.Color:=yourcolor;//new
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.font.color:=clBlack;
DBGrid1.Canvas.Textout(Field.asstring);
// DBGrid1.DefaultDrawDataCell(Rect,field,state);
end;