procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if gdselected in state then
begin
dbgrid1.Canvas.Brush.Color:=clred; //选中的单元格的颜色
dbgrid1.Canvas.FillRect(rect);
dbgrid1.Canvas.Pen.Color:=clwhite; //选中的单元格的字体颜色
if VarType(Field.Value)=varNull then
dbgrid1.Canvas.TextOut(rect.left,rect.top,'')
else
dbgrid1.Canvas.TextOut(rect.left,rect.top,Field.Value);
end;
end;