在Tstringgrid.ondrawcell事件中:
DrawText(StringGrid1.Canvas.Handle,pchar(StringGrid1.Cells[Acol,Arow]),Length(StringGrid1.Cells[Acol,Arow]),Rect,DT_WORDBREAK or DT_LEFT);
可以实现文字换行!

解决方案 »

  1.   

    DrawText(....,Length(WideString(StringGrid1.Cells[Acol,Arow])),....);
      

  2.   

    我怎么实现不了呀?
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    stringgrid1.Cells[1,1]:='29879347593875493875493875493';
    end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
    DrawText(StringGrid1.Canvas.Handle,pchar(StringGrid1.Cells[Acol,Arow]),Length(StringGrid1.Cells[Acol,Arow]),Rect,DT_WORDBREAK or DT_LEFT);end;end.没反应
      

  3.   

    to rain01(rain01) ,自动换行是在字符串的空格处换的行,你的字符串里没有空格当然不会自己换行。
      

  4.   

    DrawText(....,Length(WideString(StringGrid1.Cells[Acol,Arow])),....);
    用这句,数据长了,不能完全显示。他只能显示大概40个汉字。