Close stringgrid function of defaultdrawing
StringGrid1.Cells[cCol,cRow] := '测试1'+#13#10+'测试2';
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Area:TRect;
begin
StringGrid1.Canvas.Font.Assign
(StringGrid1.Font);
with StringGrid1,StringGrid1.Canvas do
begin
// color features
Canvas.Font.Color: = clred; // font color to red
Canvas.Brush.color: = clMoneyGreen; // green background of $
Canvas.FillRect (Rect);
FillRect (Rect);
FillRect(Rect);
Area:= Rect;
InflateRect(Area, -2, -2);
DrawText(Handle, PChar(Cells[ACol, ARow]),Length(Cells[ACol, ARow]), Area, DT_CENTER)//居中
end;
end;