procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ((ARow=2) and (ACol=3)) or ((ARow=3) and (ACol=4)) then
with TStringGrid(Sender).Canvas do
begin
Brush.Color := clRed;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, TStringGrid(Sender).Cells[ACol, ARow]); //自己算算位置吧
end;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
//if (state.=2) and (acol<>0) then
if (field.FieldNo=2) then//and (table1.RecNo=2)
with TStringGrid(Sender).Canvas do
begin
Brush.Color := clRed;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, field.AsString); //×&Ocirc;&frac14;&ordm;&Euml;&atilde;&Euml;&atilde;&Icirc;&raquo;&Ouml;&Atilde;°&Eacute;
end;
end;