在keypress里面设定
if Not (key in ['0'..'9', #8, '.',['A'..'Z']]) then
key := #0;
这样就可以了,就是限制键盘输入其他的东西。
procedure Tform.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Not (key in ['0'..'9', #8, '.',['A'..'Z']]) then
key := #0;
end;
这就是你想要的。
在KeyPress事件中写入下边的代码
XE下:
if not CharInSet(Key,['0'..'9','a'..'z']) then Key :=#0;
D7下:
if not (Key in ['0'..'9','a'..'z']) then key :=#0;