Set focus

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a form with a tab control which has a text box. When the form loads I
would like the text box to have the focus. In the form load event I placed
mytxt.focus() as the last line. When I run the form the focus is always on
the tab of the tab control. What am I doing wrong?

Regards

PS: I am using infragistics controls, in case their behaviour is different
from standard controls.
 
* "John said:
I have a form with a tab control which has a text box. When the form loads I
would like the text box to have the focus. In the form load event I placed
mytxt.focus() as the last line. When I run the form the focus is always on
the tab of the tab control. What am I doing wrong?

The focus can only be set to visible controls. In the form's 'Load'
event handler, the form and the controls are not visible and setting the
focus won't work. You can set the focus to the control by assigning the
lowest tab index to the control that should initially have the focus.
 
Put this in the Activated Event

me.YourTextBoxName.focus()


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
Or the TabControl.GotFocus() Event

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
Another way to do is use the "SelectControl". This will move the focus to
the control. I have never done this in form Load.

VJ
 
Back
Top