解决了分行问题,但没考虑字符串中间可能有回车:procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);var SS, tmpS: string; wStr: WideString; CNV:TCanvas; RowCount,H,I:Integer;begin SS := '黄汉测试asdf啊的说法阿斯顿放'; //测试数据 wStr := SS; CNV:= StringGrid1.Canvas; H:= CNV.TextHeight('A'); RowCount :=0; while wStr<>'' do begin I:=1; While (I<=Length(wStr)) and ( CNV.TextWidth( Copy(wStr,1,I) )<= (Rect.Right-Rect.Left-2)) Do Inc(I); if I<=Length(wStr) Then Dec(I); tmpS := Copy(wStr,1,I); system.Delete(wStr,1,I); if (RowCount mod 2) = 0 then CNV.Font.Color := Clred else CNV.Font.Color := ClBlue; CNV.TextOut(Rect.Left+2, Rect.Top + RowCount*H, tmpS); Inc(RowCount); end;end;