现在有 EDIT1(值为asdf)
EDIT2(值为asdfsd)
EDIT3
按钮BUTTON
请问在BUTTON的事件中如何写才能满足下面的条件?
当EDIT1获得焦点并且EDIT1的值等于asdf进入form2.
当EDIT2获得焦点并且EDIT2的值等于asdfsd进入form3.
.
.
.
.
.
EDIT2(值为asdfsd)
EDIT3
按钮BUTTON
请问在BUTTON的事件中如何写才能满足下面的条件?
当EDIT1获得焦点并且EDIT1的值等于asdf进入form2.
当EDIT2获得焦点并且EDIT2的值等于asdfsd进入form3.
.
.
.
.
.
if (Edit1.Focused) and (Edit1.text = 'asdf') then
begin
form2.Show;
end;
if (EDIT2.Focused) and (EDIT2.text = asdfsd) then
begin
form3.Show;
end
//......
if (Edit1.Focused) and (Edit1.text = 'asdf') then
begin
form2.Show;
end;
if (EDIT2.Focused) and (EDIT2.text = 'asdfsd') then
begin
form3.Show;
end
//......
k:intgeger;
begin
if ((TEdit(FindComponent('edit'+inttostr(1)))).Focused)and
((TEdit(FindComponent('edit'+inttostr(1)))).Text='asdf') then Form2.ShowModal;
if ((TEdit(FindComponent('edit'+inttostr(2)))).Focused)and
((TEdit(FindComponent('edit'+inttostr(2)))).Text='asdfsd') then Form3.ShowModal;
end;edit更多的话用循环就OK!!!
begin
form2.Show;
end;
if (EDIT2.Focused) and (EDIT2.text = asdfsd) then
begin
form3.Show;
end
begin
Edit1.SetFocus;
form2.Show;
end;
if EDIT2.text = 'asdfsd' then
begin
Edit2.SetFocus;
form3.Show;
end
一个焦点在button上面 另外还有edit保持着焦点? 这怎么可能
如果edit里面的值等于某个字符串 就弹出窗体
EDIT1
EDIT2
EDIT3
.
.
.
然后一个BUTTON,当EDIT1的内容为蓝色时(就是获得焦点吧),点BUTTON 进入FORM1
当EDIT2的内容为蓝色时(就是获得焦点吧),点BUTTON 进入FORM2
.
.
.
这样只要判断text和tag就可以得判断你要的东西了
var
i:integer;
begin for i:=0 to ControlCount-1 do
begin
if (Controls[i] is TEdit) then
begin
if TEdit(Controls[i]).Name = TEdit(Sender).Name then
TEdit(Sender).Tag := 1
else
TEdit(Sender).Tag := 0 ;
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Tag = 1) and (edit1.Text = 'Edit1') then
ShowMessage('Edit1'); if (Edit2.Tag =1) and (edit2.Text = 'Edit2') then
ShowMessage('Edit2'); if (Edit3.Tag =1) and (edit3.Text = 'Edit3') then
ShowMessage('Edit3');end;
begin
if TEdit(Controls[i]).Name = TEdit(Sender).Name then
TEdit(Controls[i]).Tag := 1
else
TEdit(Controls[i]).Tag := 0 ;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if Edit1.Font.Color = clblue then
begin
form2.show;
end;
end;
下午结帖。