Change focus

M

Mervin Williams

I have a form with a datagrid and two buttons on it. Upon opening the form,
focus goes immediately to the datagrid. How do I set focus onto one of the
buttons. I've tried to use "btnSave.Focus()", but to no avail.

Please help.

Mervin Williams
 
T

Tim Wilson

Try setting the TabIndex property on the controls to appropriate values, and
ensure that the TabStop property is set to "true" for any controls that
should be hit while tabbing.
 
M

Mervin Williams

Thanks, that was the answer!


Tim Wilson said:
Try setting the TabIndex property on the controls to appropriate values,
and
ensure that the TabStop property is set to "true" for any controls that
should be hit while tabbing.
 
H

Herfried K. Wagner [MVP]

Mervin Williams said:
I have a form with a datagrid and two buttons on it. Upon opening the
form, focus goes immediately to the datagrid. How do I set focus onto one
of the buttons. I've tried to use "btnSave.Focus()", but to no avail.

In addition to the other reply: If you do not want to change the tab order
of the controls, consider calling the button's 'Select' method instead of
its 'Focus' method.
 

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