if ActiveControl = Edit1 then .... else if ActiveControl = ComboBox1 then ....
我是利用同一个OnEnter,但不知道是不是哪个代码?是吗?不是吗?请回答!谢谢!
procedure TForm1.Edit1Enter(Sender: TObject); begin if (Sender is TEdit) then ShowMessage('你进入了' + TEdit(Sender).Name) else if (Sender is TComboBox) then ShowMessage('你进入了' + TComboBox(Sender).Name); end;
procedure TForm1.Edit1Enter(Sender: TObject); begin if (Sender=Edit1) then ShowMessage('这是'+EDIT1.NAME) else if (Sender=ComboBox1) then ShowMessage('这是'+ComboBox1.Name); end;
if (ActiveControL is Tedit) then Tedit(ActiveControl).text:='这是EDIT'; if (ActiveControl is Tcombobox) then Tcombobox(ActiveControl).text:='这是combobox';
....
else if ActiveControl = ComboBox1 then
....
begin
if (Sender is TEdit) then
ShowMessage('你进入了' + TEdit(Sender).Name)
else if (Sender is TComboBox) then
ShowMessage('你进入了' + TComboBox(Sender).Name);
end;
begin
if (Sender=Edit1) then
ShowMessage('这是'+EDIT1.NAME)
else if (Sender=ComboBox1) then
ShowMessage('这是'+ComboBox1.Name);
end;
if (ActiveControl is Tcombobox) then Tcombobox(ActiveControl).text:='这是combobox';