...........

解决方案 »

  1.   

    每一行输入个数限制:maxlength
      

  2.   

    procedure TForm1.Memo1Change(Sender: TObject);
    const
     MaxLineCount=5;
    begin
        if Memo1.Lines.Count>MaxLineCount then
            Memo1.Perform(EM_UNDO,0,0);
        Memo1.Perform(EM_EMPTYUNDOBUFFER,0,0);
    end;
    //限制输入行数
      

  3.   

    WANGXUELLD:-------
      每一行输入个数限制:maxlength..
      tmemo没有这个功能吧!!
      

  4.   

    procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    var
      CurrentRow: integer;
      MaxLineCount,MaxLength: integer;
    begin
      MaxLineCount:=5;
      MaxLength:=10;
      CurrentRow:=self.Memo1.CaretPos.Y;
      if (Key=#13) then
      begin
        if (self.Memo1.Lines.Count=MaxLineCount) then
          Key:=#0;
      end
      else if Key<>Char(VK_BACK) then
      begin
        if (Length(self.Memo1.Lines[CurrentRow])=MaxLength) then
          Key:=#0;
      end;
    end;
      

  5.   

    上面的有问题,修改如下:procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    const
      MaxLineCount=5;
      MaxLength=10;
    var
      CurrentRow: integer;
    begin
      CurrentRow:=self.Memo1.CaretPos.Y;
      if key=#13 then
      begin
        if self.Memo1.Lines.Count=MaxLineCount then
          Key:=#0;
      end
      else if Key<>Char(VK_BACK) then
      begin
        if Length(self.Memo1.Lines[CurrentRow])>=MaxLength then  //用"="的话最后一个字符输入一个全角字就出问题了
          Key:=#0;
      end;
    end;