Move to the next control

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
 
H

Herfried K. Wagner [MVP]

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.
 
C

Chris

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
 
H

Herfried K. Wagner [MVP]

Addendum:

.... or even shorter, use 'Control.SelectNextControl' directly. The current
control can be obtained using 'Me.ActiveControl'.
 
C

Curtis

This is what you probably want to do, very simple.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top