怎样限制Edit的输入 我想在Edit中输入数字,其他的东西一概抛弃,请问有什么办法可以做到。请高手告赐教最简单的办法。谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin if not (Key in ['0'..'9']) then Key := #0;end; 第1方法:改用maskedit控件。另外就是:在edit的onkeypress加入限制判断。代码不写了. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin if not (Key in ['0'..'9','.']) then Key := #0;end;还得要能输入小数据点啊:) 还有方法: SetWindowLong( Edit1.Handle, GWL_STYLE, GetWindowLong(Edit1.Handle, GWL_STYLE) Or ES_NUMBER ); if not (Key in ['0'..'9','.',#8]) then Key := #0;再加一個#8吧! procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin if not (Key in ['0'..'9','.',#8]) then Key := #0;end;还得要能输入退格鍵啊 :) 文本类型能加1吗 还有一个问题有个错误:"多步操作产生错误,请检查每一步的状态值 " 请问delphi里如何获得“星期几”信息? 急救!!!ehlib怎么装?? 嘿嘿,要一个取时间的算法!!不怕死的进来!! query returned multiple result sets 有谁遇到过?? 简单的问题,up有分! 当点击dbgrid的任一列的标题时,怎样才能得到该列的字段名。 软件更新的办法 到底有没有人在WIN98下成功地配置过DCOM? 如何在中间层动态创建DATASET并和DATASETPROVIDER绑定 如何将资源文件内内容另存
begin
if not (Key in ['0'..'9']) then Key := #0;
end;
另外就是:在edit的onkeypress加入限制判断。代码不写了.
begin
if not (Key in ['0'..'9','.']) then Key := #0;
end;
还得要能输入小数据点啊:)
SetWindowLong( Edit1.Handle, GWL_STYLE, GetWindowLong(Edit1.Handle, GWL_STYLE) Or ES_NUMBER );
再加一個#8吧!
begin
if not (Key in ['0'..'9','.',#8]) then Key := #0;
end;
还得要能输入退格鍵啊 :)