如何改变memo控件的行间距?

解决方案 »

  1.   

    font???好像不行。。
    关注。
      

  2.   

    帮你找的代码,没试过....姑且看看...//------限制memo的行数和行宽---------
    unit Unit1;interfaceuses
      SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
      StdCtrls, ExtCtrls, Forms;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        procedure FormCreate(Sender: TObject);
        procedure Memo1KeyPress(Sender: TObject; var Key: Char);
      public
        MaxCharsPerLine, MaxLines: Integer;
        function MemoLine: Integer;
        function LineLen(r: Integer): Integer;
        function NRows: Integer;
      end;var
      Form1: TForm1;implementation{$R *.DFM}function TForm1.NRows: Integer;
    begin
      with Memo1 do
        Result := 1 + SendMessage(Handle, EM_LINEFROMCHAR, GetTextLen-1, 0);
    end;function TForm1.LineLen(r: Integer): Integer;
    var r1, r2: Integer;
    begin
      with Memo1 do begin
        r1 := SendMessage(Handle, EM_LINEINDEX, r, 0);
        if (r < NRows-1) then
          r2 := SendMessage(Handle, EM_LINEINDEX, r+1, 0)-2 {-CR/LF}
        else
          r2 := GetTextLen;
      end;
      Result := r2-r1;
    end;function TForm1.MemoLine: Integer;
    begin
      with Memo1 do
        Result := SendMessage(Handle, EM_LINEFROMCHAR, SelStart, 0);
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      MaxCharsPerLine := 8;
      MaxLines := 4;
    end;procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    begin
      with Memo1 do begin
        case Key of
          ' '..#255: if (LineLen(MemoLine) >= MaxCharsPerLine) then
            Key := #0;
          #10, #13: if (NRows >= MaxLines) then
            Key := #0;
          #8: if (SelStart = SendMessage(Handle, EM_LINEINDEX, MemoLine, 0)) then
            Key := #0;
        end;
      end;
    end;end.
      

  3.   

    关注,不好改吧...xiaoyan21(明月心) 朋友给的代码是限制memo中输入行数和行宽的...偶记得IP3000中的DBRichEdit好象是可以改的,建议考虑...
      

  4.   

    procedure TFServer.Button2Click(Sender: TObject);
    var
      ACanvas: TCanvas;
      ARect : TRect;
      str: string;begin
      str := 'hello the world';  ARect := Rect(0,0,memo1.Width,50);
      ACanvas := TCanvas.Create;
      ACanvas.Handle := GetDC(Memo1.Handle);
      ACanvas.TextRect(ARect,0,0,str);
    end;
    其实memo没有办法改变行间距,据说rxlib里面的rxrichedit有这个功能
    不过我没有用过
      

  5.   

    naughtyboy(一切都是为了明天) :
    这样也行?呵呵,服了。
    不过这样的字是画上去的,还得考虑重绘,而且人家要是想从中粘一段儿出来...
      

  6.   

    在窗体上放一个image控件后,然后将它的brush.color设置为白色,这样就像一个memo了,
    但是不知道怎么样接收键盘的输入,有办法让它接收到键盘的输入的字符吗?
      

  7.   

    那你为什么不用listbox,listbox有itemheight选项啊