如何控制edit中的字符输入? 如何控制在edit中只输入数字?另外我怎么知道一些字符的Key值,如回车键key=13,那么退格键等其它的呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if key not in [0..9] then key:=#0; if not key in ['0'..'9',#8,#46] then key := #0; 在KeyDown事件里通过对Key参数的控制来实现procedure DoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); if not (key in ['0'..'9'],#8) thenbegin key:=#0; messagebeep(1);end;#8是退格键,应该让它也起作用2.很简单在edit的onkeydown中写showmessage(inttostr(key)) 在OnKeyPress中 if key not in [0..9] then key:=#0;在知道Key值,查ASCII 码表,或在Delphi帮助的索引中 敲 Virtual key codes //只允许输入数字 if not (Key in ['0'..'9',#13,#8,#46]) then//不应该把回车和DEL、BACKSPACE过滤掉 begin key := #0; end; 请教一个关于对数据库做的问题? 如何在运行过程中用一个按钮中断程序? 请教P2P的打洞问题? 审核流程的数据库结构怎样设计比较好? 关于发送没有窗口句炳的消息问题。提供代码 数据库恢复!急! 怎样用DELPHI制作XP那样的界面!!! 高手都说难的问题:Mysql能否在一次TQUERY.EXECUTE执行同时使用两条INSERT语句?或使用方法是怎样的? 关于button的颜色设置 jitou Delphi的QuickRep怎样控制!(有点难度哦) 想找兼职
key := #0;
procedure DoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
key:=#0;
messagebeep(1);
end;
#8是退格键,应该让它也起作用
2.很简单
在edit的onkeydown中写
showmessage(inttostr(key))
if key not in [0..9] then key:=#0;在知道Key值,查ASCII 码表,或在Delphi帮助的索引中 敲 Virtual key codes
if not (Key in ['0'..'9',#13,#8,#46]) then//不应该把回车和DEL、BACKSPACE过滤掉
begin
key := #0;
end;