最近我在做一个学生信息系统的查询模块,由于刚刚学Delphi遇到了一些问题:
查询的第一个选择条件是combobox1----政治面貌,性别,专业,等等
在后面呢我设置了5个bomobox分别为combobox2,combobox3,combobox4,combobox5,combobox6,思想是这样的:
比如选择第一条件是政治面貌的时候,那么第二条件则马上显示相应的选项如 团员或者党员,而其他的combobox则隐藏,选择第一条件是性别时候,那么第二条件马上显示男或女,其他的combobox也隐藏(5个combobox组件放在一个坐标上,位置重复)但是在开发的时候碰到了问题,非要点击一下确定按钮,才能实现上述所说的,没有点击确定按钮前,他们的显示状态是最后一个combobox6的显示状态,寻解~!
谢谢各位`!
我的代码如下:
procedure TForm3.Button1Click(Sender: TObject);begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
case ComboBox1.ItemIndex of
0:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
edit1.SetFocus; if edit1.Text='' then showmessage('请输入查询条件!')
else
begin
ADOTable1.Filtered:=false;
ADOTable1.Locate('student_ID',trim(edit1.Text),[]);
DBGrid1.SetFocus;
if ADOTable1.FieldByName('student_ID').value<>trim(edit1.text) then
showmessage('查询无此记录,请确认输入了9位的有效学号') end; end;
1:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
edit1.SetFocus;
ADOTable1.Filtered:=false;
if edit1.Text='' then showmessage('请输入查询条件!')
else
with ADOTable1 do
begin
ADOTable1.filter:= 'student_Name='+QuotedStr(edit1.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
2:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=true;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
combobox2.SetFocus;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'student_Sex='+QuotedStr(combobox2.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
3:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=true;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'politi_feature='+QuotedStr(combobox3.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
4:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=true;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'location='+QuotedStr(combobox4.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件省份例如山东省');
end;
end;
5:begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=true;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'nation='+QuotedStr(combobox5.Text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件民族例如汉');
end;
end;
6:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=true;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'profession='+QuotedStr(combobox6.Text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件专业');
end;
end;
7:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
// form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
if edit1.Text='' then showmessage('请输入查询条件!')
else
with ADOTable1 do
begin
ADOTable1.filter:= 'graduate_school='+QuotedStr(edit1.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件毕业学校');
end;
form3.combobox6.visible:=false;
end; end;
end;end.
查询的第一个选择条件是combobox1----政治面貌,性别,专业,等等
在后面呢我设置了5个bomobox分别为combobox2,combobox3,combobox4,combobox5,combobox6,思想是这样的:
比如选择第一条件是政治面貌的时候,那么第二条件则马上显示相应的选项如 团员或者党员,而其他的combobox则隐藏,选择第一条件是性别时候,那么第二条件马上显示男或女,其他的combobox也隐藏(5个combobox组件放在一个坐标上,位置重复)但是在开发的时候碰到了问题,非要点击一下确定按钮,才能实现上述所说的,没有点击确定按钮前,他们的显示状态是最后一个combobox6的显示状态,寻解~!
谢谢各位`!
我的代码如下:
procedure TForm3.Button1Click(Sender: TObject);begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
case ComboBox1.ItemIndex of
0:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
edit1.SetFocus; if edit1.Text='' then showmessage('请输入查询条件!')
else
begin
ADOTable1.Filtered:=false;
ADOTable1.Locate('student_ID',trim(edit1.Text),[]);
DBGrid1.SetFocus;
if ADOTable1.FieldByName('student_ID').value<>trim(edit1.text) then
showmessage('查询无此记录,请确认输入了9位的有效学号') end; end;
1:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
edit1.SetFocus;
ADOTable1.Filtered:=false;
if edit1.Text='' then showmessage('请输入查询条件!')
else
with ADOTable1 do
begin
ADOTable1.filter:= 'student_Name='+QuotedStr(edit1.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
2:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=true;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
combobox2.SetFocus;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'student_Sex='+QuotedStr(combobox2.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
3:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=true;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'politi_feature='+QuotedStr(combobox3.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录');
end;
end;
4:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=true;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'location='+QuotedStr(combobox4.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件省份例如山东省');
end;
end;
5:begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=true;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'nation='+QuotedStr(combobox5.Text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件民族例如汉');
end;
end;
6:
begin
form3.Edit1.Visible:=false;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
form3.ComboBox6.Visible:=true;
ADOTable1.Filtered:=false;
//if edit1.Text='' then showmessage('请输入查询条件!')
//else
with ADOTable1 do
begin
ADOTable1.filter:= 'profession='+QuotedStr(combobox6.Text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件专业');
end;
end;
7:
begin
form3.Edit1.Visible:=true;
form3.combobox2.visible:=false;
form3.ComboBox3.visible:=false;
form3.ComboBox4.Visible:=false;
form3.ComboBox5.Visible:=false;
// form3.ComboBox6.Visible:=false;
ADOTable1.Filtered:=false;
if edit1.Text='' then showmessage('请输入查询条件!')
else
with ADOTable1 do
begin
ADOTable1.filter:= 'graduate_school='+QuotedStr(edit1.text);
ADOTable1.Filtered:=true;
if ADOTable1.RecordCount=0 then showmessage('查询无此记录请确认条件毕业学校');
end;
form3.combobox6.visible:=false;
end; end;
end;end.
解决方案 »
- 新手问题随机数
- 为什么Delphi中的颜色与取色工具取的颜色不一致?
- 大家帮忙看看,这个SQL应如何写才能运行
- 各位高手给介绍一下有关Delphi类编程的经验
- 怎么样在DBGRID中点击标题栏实现跟联接(ADO,BDE,DBEXPRESS等)无关的排序
- 怎样让dbgrid对数据库的数据即时更新?
- UP有分,如何在新增记录时实现“20021218001”,“20021218002”一样的编号呢?
- 如何得到一个画线的控件
- StringGrid在单元格中如何换行?急急急急急急急!!!!!
- 在BDE里新建了MSSQL类型的别名,然后打开别名旁边的“+”,弹出对话框,要求输入用户名和密码,请问为什么?如何解决?谢了!
- 如何用delphi写一个ocx(比如1+2+3+4),然后asp去调它并显示结果.
- richedit组件如何实现个别字体的颜色改变...
应该写在onDropDown事件