自己可以适当修改一下:
procedure TForm1.FormCreate(Sender: TObject);
begin
stringgrid1.cells[1,1]:='ABaaaaaefghFFF';
stringgrid1.cells[1,2]:='ABaaaaaefghFFF';
stringgrid1.cells[2,1]:='ABaaaaaefghFFF';
stringgrid1.cells[2,2]:='ABaaaaa';
stringgrid1.RowHeights[1]:=40;
stringgrid1.RowHeights[2]:=40;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
s:string;
begin
with StringGrid1 do
begin
s:=StringGrid1.cells[acol,arow];
if length(s)>10 then
begin
canvas.brush.color:=$00ffff;
canvas.font.color:=$0000ff;
canvas.Rectangle(rect);
canvas.TextOut(rect.Left ,rect.Top,copy(s,1,10));
canvas.TextOut(rect.Left ,rect.Top+20,copy(s,11,length(s)-10));
end
else
inherited;
end;
end;