条件限制

famer 2005-03-31 04:32:41
if combobox1.Text='编号' then
begin
adoquery1.SQL.Clear;
adoquery1.Close;
adoquery1.SQL.Text:='select * from db_name where id='+edit1.Text+'';
adoquery1.Open;


请问上面那个代码,当combobox1.text='编号' 时我想让 edit1这个文本框只能输入数字,请问用什么办法能实现。
...全文
59 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hn_tzy 2005-03-31
  • 打赏
  • 举报
回复
在EDIT1的KEYDOWN和KEYUP过程中判断
jasonmark 2005-03-31
  • 打赏
  • 举报
回复
在combobox1的keypress写:
if (combobox1.Text='编号') and ((key <'0') or (key > '9')) and (key <> #8) then
key := #0;
smiler007 2005-03-31
  • 打赏
  • 举报
回复
在EDIT的OnKeyPress事件中

if (key=#13) and (combobox1.text='编号') then
if not (key in ['0'..'9']) then key:=#0;
jinjazz 2005-03-31
  • 打赏
  • 举报
回复
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowLong(Edit1.Handle, GWL_STYLE) or
ES_NUMBER);
end;

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧