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
FillRect(Rect);
Area:= Rect;
InflateRect(Area, -2, -2);
DrawText(Handle, PChar(Cells[ACol, ARow]),Length(Cells[ACol, ARow]), Area, DT_CENTER)//居中
end;
end;
来源:https://www.cnblogs.com/zyb2016/p/11639525.html