首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

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

2012-02-27 
如何控制tmemo的输入行数和每一行的输入字符数...........[解决办法]上面的有问题,修改如下:Delphi(Pascal

如何控制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; 

热点排行