Simple question - changing focus

R

Rob

It used to be "After Update" in Access, but in vb.net...

After a user enters something into a textbox and presses the Enter button, I
want the focus to move to another texbox.

Which one do you use ?

And do I simply put... TextBoxtoGoTo.Focus() in that event ?

Thanks
 
H

Herfried K. Wagner [MVP]

Rob said:
After a user enters something into a textbox and presses the Enter button,
I want the focus to move to another texbox.

Which one do you use ?

And do I simply put... TextBoxtoGoTo.Focus() in that event ?

Yes, you can set the focus to a certain control by calling its 'Focus'
method.
 
H

Hal Rosser

Shouldn't the focus move when the user presses the <tab> key, rather than
the <enter> key?
I would think you should reserve action from the <enter> key to operate the
default command button.
Most Users are accustomed to the <enter> key being the 'final step' in a
data entry sequence. On the other hand, users are accustomed to using the
<tab> key to move to the next text box.
 
R

Rob

Thanks Hal,

I agree... but just for knowledge sake, which VB.net event fires the
"OnEnter" action for a text box ?

Rob
 
H

Herfried K. Wagner [MVP]

Rob said:
but just for knowledge sake, which VB.net event fires the
"OnEnter" action for a text box ?

I suggest to read the documentation for 'Control.Enter'.
 
R

Rob

Hi Herfried,

I think I asked the wrong question... let's say the user types in a value
and presses the "Enter" button. What event is fired just after the "Enter"
button is pressed ?

I believe the Control.Enter event is fired when the user first enters a
character in the textbox.

Thanks,
Rob
 
P

Phill. W

Rob said:
It used to be "After Update" in Access, but in vb.net...

After a user enters something into a textbox and presses the Enter
button, I want the focus to move to another texbox.

To change focus when the Enter key is pressed, handle the KeyDown
(and/or Keypress) methods calling the [Control].SelectNextControl
method.

However, by doing so, you may be upsetting the more "natural"
flow of focus events that you would normally get in a .Net application.

I'd suggest you educate your ex-Access users to rejoin the Real
World and use the Tab key for moving around fields in their "new"
applications ;-)

HTH,
Phill W.
 
H

Herfried K. Wagner [MVP]

Rob said:
I think I asked the wrong question... let's say the user types in a value
and presses the "Enter" button. What event is fired just after the
"Enter" button is pressed ?

The button's 'Click' event.
I believe the Control.Enter event is fired when the user first enters a
character in the textbox.

It's fired when the focus is set to the textbox.
 

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

Similar Threads


Top