StringGrid1.Cells[1,1]:= 'AAA'+#13+'bbb';

解决方案 »

  1.   

    把DefaultDrawing设为false
    然后在DrawCell里面自己画。
      

  2.   

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

  3.   

    我要写两行
    abc
    efg怎么处理呀?drawtext怎么没有看到写字符串的地方?
      

  4.   

    以上代码是在显示不下时换行显示, 自己看一下API帮助吧,现在没空仔细说明。
      

  5.   

    确实如此,delphi5里面的stringgrid好象不能用drawtext,用了也和没用一样
      

  6.   

    首先要将StringGrid的DefaultDrawing设为False;
    放置一个Button和一个StringGrid;
    然后是下面的代码:
    procedure TForm1.Button1Click(Sender: TObject);
    var I,J:integer;
    begin
      for I:=1 to 4 do
      begin
        for J:=1 to 4 do
        begin
          StringGrid1.Cells[I,J]:='Hello'#13'everyone';//#13代表换行处
        end;
      end;
    end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var R:TRect;begin
      R:=StringGrid1.CellRect(ACol,ARow);  With StringGrid1 do
      begin
        DrawText(StringGrid1.Canvas.Handle,PChar(StringGrid1.Cells[ACol,ARow]),
                Length(StringGrid1.Cells[ACol,ARow]),R,DT_WORDBREAK);
      end;
    end;
    我在Delphi5和6都编译通过,运行正常。