How do I position the cursor to a specif textbox

T

Tony Johansson

Hello!

I want to be able to position the curson to a specific textbox in certain
occasions.
How can I do that ?

//Tony
 
T

Tony Johansson

Hello!

This works in the situation when I input something that is not valid and
want to set the cursor back so a
correction can be made.

Now I want to set the cursor as soon as the form is displayed.
In a way fetch the event when the form is displayed and here set the cursor
to a specic textbox.

//Tony
 
B

Bjørn Brox

Tony Johansson skrev:
Hello!

This works in the situation when I input something that is not valid and
want to set the cursor back so a
correction can be made.

Now I want to set the cursor as soon as the form is displayed.
In a way fetch the event when the form is displayed and here set the cursor
to a specic textbox.

As Peter says: use Control.Focus()

If you want to do this when the form is loaded, well do that in the Load
event.

If you want a specific position or having the initial text selected you
use the selection parameters of the text box as well.
 
J

joecool1969

Tony Johansson skrev:




As Peter says: use Control.Focus()

If you want to do this when the form is loaded, well do that in the Load
event.

If you want a specific position or having the initial text selected you
use the selection parameters of the text box as well.

I have found that Control.Focus() doesn't work in the form Load event,
but does in the form Shown event.
 

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