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

設置RichEdit只能輸入一行資料,如何做

2012-03-05 
設置RichEdit只能輸入一行資料,怎么做?如題:即不能回車換行,只可以輸入一行。謝謝![解决办法]这样行不行:pr

設置RichEdit只能輸入一行資料,怎么做?
如題:即不能回車換行,只可以輸入一行。
謝謝!

[解决办法]
这样行不行:

procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if (Key = #13) or (Key = #10) then Key := #0;
end;
[解决办法]
procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then key:= #0;
end;

procedure TForm1.RichEdit1Change(Sender: TObject);
begin
if richedit1.Lines.Count> 1 then
begin
keybd_event(VK_BACK, MapVirtualKey(VK_BACK, 0), 0, 0);
keybd_event(VK_BACK, MapVirtualKey(VK_BACK, 0), KEYEVENTF_KEYUP, 0);
end;
end;
[解决办法]
用edit得了
[解决办法]
keypress要把form的key preview属性改成true

[解决办法]
直接 设置 WantReturns 属性为 false 就行了 ,什么代码都不用写

热点排行