| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 524 人关注过本帖
标题:控件中事件的调用
只看楼主 加入收藏
liuqiang_sy
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2007-3-13
收藏
 问题点数:0 回复次数:1 
控件中事件的调用

procedure TForm1.Edit1Exit(Sender: TObject);
begin
if edit1.Text='' then
begin
label4.Caption:='用户名不能为空';
label4.Font.Color:=clred;
end
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select * from DL where ID='''+EDIT1.Text+'''';
ADOQUERY1.Open;
if adoquery1.RecordCount<>0 then
begin
label4.Caption:='该用户名以存在';
label4.Font.Color:=clred;
end
else
begin
label4.Caption:='';
label4.Font.Color:=clbtnface;
end;
end;
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
if edit2.Text='' then
begin
label5.Caption:='请输入密码';
label5.Font.Color:=clred;
end
else
begin
label5.Caption:='';
label5.Font.Color:=clbtnface;
end;
end;

procedure TForm1.Edit3Exit(Sender: TObject);
begin
if edit3.Text='' then
begin
label6.Caption:='请输入密码';
label6.Font.Color:=clred;
end
else
begin
if edit3.Text<>edit2.Text then
begin
label6.Caption:='确认密码不一致';
label6.Font.Color:=clred;
end
else
begin
label6.Caption:='';
label6.Font.Color:=clbtnface;
end;
end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Close;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if edit1.Text='' then
begin
label4.Caption:='用户名不能为空';
label4.Font.Color:=clred;
showmessage('您填写的信息有错误,请跟据提示修改!');
end
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select * from DL where ID='''+EDIT1.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount<>0 then
begin
label4.Caption:='该用户名以存在';
label4.Font.Color:=clred;
showmessage('您填写的信息有错误,请跟据提示修改!');
end
else
begin
label4.Caption:='';
label4.Font.Color:=clbtnface;
end
end;


if edit2.Text='' then
begin
label5.Caption:='请输入密码';
label5.Font.Color:=clred;
showmessage('您填写的信息有错误,请跟据提示修改!');
end
else
begin
label5.Caption:='';
label5.Font.Color:=clbtnface;
end;


if edit3.Text='' then
begin
label6.Caption:='请输入密码';
label6.Font.Color:=clred;
showmessage('您填写的信息有错误,请跟据提示修改!');
end
else
begin
if edit3.Text<>edit2.Text then
begin
label6.Caption:='确认密码不一致';
label6.Font.Color:=clred;
showmessage('您填写的信息有错误,请跟据提示修改!');
end
else
begin
label6.Caption:='';
label6.Font.Color:=clbtnface;
end;
end;

end;
end.
怎么样在TForm1.Button1Click中调用TForm1.Edit1Exit\TForm1.Edit2Exit\TForm1.Edit3Exit.

搜索更多相关主题的帖子: 控件 
2007-04-18 19:10
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
收藏
得分:0 
首先为什么要在label4中填入信息(当然也没错),你可以用弹出窗口来处理这个问题.
至于调用edit的exit的问题,这样就行了:edit1.onexit(edit1),哈,你试试.

代码融余厉害,花里胡哨的东西太多,呵呵.
纯属个人意见,不当之处,海涵海涵


小猫说:给我10元钱
2007-04-18 19:20
快速回复:控件中事件的调用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018280 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved