S
siso
Unregistered / Unconfirmed
GUEST, unregistred user!
如下:edit1只可输入数字和字母及退格键
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
但如果我需要支持复制和粘贴,于是我改为
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8,#17]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
#17是Ctrl的键盘码,可是还是不能按Ctrl+c或Ctrl+v
后来得到帮助如下 :
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8,#3,#22]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
可以复制和粘贴了,但我不清楚#3,和#22是什么意思?请各位告诉我一下。谢了!
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
但如果我需要支持复制和粘贴,于是我改为
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8,#17]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
#17是Ctrl的键盘码,可是还是不能按Ctrl+c或Ctrl+v
后来得到帮助如下 :
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9','a'..'z',#8,#3,#22]) then
begin
key:=#0;
MessageBeep(1);
end;
end;
可以复制和粘贴了,但我不清楚#3,和#22是什么意思?请各位告诉我一下。谢了!