Move to the next control

  • Thread starter Thread starter Vayse
  • Start date Start date
V

Vayse

I have a text box, with a command button next to it. When the button is
pressed, I want to run some code.
Then pass the focus to the next control.
How do I do this?

Thanks
Vayse
 
Vayse said:
I have a text box, with a command button next to it. When the button is
pressed, I want to run some code.
Then pass the focus to the next control.

Determine the next control using 'Control.GetNextControl' and then call the
control's 'Focus' method.
 
Vayse said:
I have a text box, with a command button next to it. When the button is
pressed, I want to run some code.
Then pass the focus to the next control.
How do I do this?

Thanks
Vayse

Did you have a look at Tomb's post right before yours?


Two simple ways:
button1.selectnextcontrol

or

SelectNextControl(Me.ActiveControl, True, True, True, True)

Good Luck
Chris
 
Addendum:

.... or even shorter, use 'Control.SelectNextControl' directly. The current
control can be obtained using 'Me.ActiveControl'.
 
This is what you probably want to do, very simple.

Dim control As New Control
control = Me.GetNextControl(Button1, True)
control.Focus()
 
Back
Top