读书人

怎么控制tmemo的输入行数和每一行的输

发布时间: 2012-02-27 10:00:22 作者: rapoo

如何控制tmemo的输入行数和每一行的输入字符数
...........

[解决办法]
上面的有问题,修改如下:

Delphi(Pascal) code
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; 

读书人网 >.NET

热点推荐