procedure TForm1.RadioButton1Click(Sender: TObject); begin RadioButton1.Checked:=True; Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)); end;
procedure TForm1.RadioButton2Click(Sender: TObject); begin RadioButton2.Checked:=True; Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)); end;
procedure TForm1.RadioButton3Click(Sender: TObject); begin RadioButton3.Checked:=True; Edit2.Enabled:=True; Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)+';请分别输入!'); end;
procedure TForm1.Button1Click(Sender: TObject); begin if (not RadioButton1.Checked)and (not RadioButton2.Checked)and (not RadioButton3.Checked)then begin showmessage('请选择查询方式!'); Exit; end; if RadioButton1.Checked then if Table1.FindKey([Edit1.Text]) then showmessage('您要查询的记录已找到!') else showmessage('对不起,没有您要查询的记录!'); if RadioButton2.Checked then begin Table1.FindNearest([Edit1.text]); showmessage('已找到相关记录!'); end; if RadioButton3.Checked then begin Table1.SetRange([Edit1.Text],[Edit2.Text]); Edit2.Enabled:=False; end; end;
{RadioButton1控件的单击事件} procedure TForm1.RadioButton1Click(Sender: TObject); begin RadioButton1.Checked:=True;//RadioButton1控件设为选中状态 Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo));//弹出窗口提示,范围是上面赋值的MinNo到MaxNo,IntToStr是字符串类型转换成整型 end;
{同RadioButton1Click} procedure TForm1.RadioButton2Click(Sender: TObject); begin RadioButton2.Checked:=True; Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)); end;
{同RadioButton1Click} procedure TForm1.RadioButton3Click(Sender: TObject); begin RadioButton3.Checked:=True; Edit2.Enabled:=True;//文本框2设置为可编辑状态 Showmessage('编号的最大范围为'+inttostr(MinNo)+'~'+inttostr(MaxNo)+';请分别输入!'); end;
{button按钮控件单击事件} procedure TForm1.Button1Click(Sender: TObject); begin if (not RadioButton1.Checked)and (not RadioButton2.Checked)and (not RadioButton3.Checked)then//判断如果RadioButton1,2,3同事没有被选中时 begin showmessage('请选择查询方式!');//弹出窗口提示 Exit;//直接跳出,下面代码不再执行 end; if RadioButton1.Checked then //如果RadioButton1被选中了 if Table1.FindKey([Edit1.Text]) then//如果选中状态下,文本框1中内容在表数据中找到了,提示记录找到,否则提示没找到 showmessage('您要查询的记录已找到!') else showmessage('对不起,没有您要查询的记录!'); if RadioButton2.Checked then begin //同上,如果找到提示找到记录 Table1.FindNearest([Edit1.text]); showmessage('已找到相关记录!'); end; if RadioButton3.Checked then begin //如果RadioButton3被选中,在表中查找文本框1和文本框2的值之间的数据 Table1.SetRange([Edit1.Text],[Edit2.Text]); Edit2.Enabled:=False;//文本框2不可编辑状态 end; end;