I have text1 and text 2.
Every time the form load, the cursor focus on the text2. I want the cursor focus on the text1 while form load. How Could I do?
I have set focus on the form load like this
text1.setfocus but I got the error..:confused:
Printable View
I have text1 and text 2.
Every time the form load, the cursor focus on the text2. I want the cursor focus on the text1 while form load. How Could I do?
I have set focus on the form load like this
text1.setfocus but I got the error..:confused:
During design time make the TabIndex Property of Text1 to 0.
Thank you so much so simple..:D
No problem. You can now mark this thread resolved. Thanks!
Just as an FYI.....this is because all of the code in the Form Load will execute before the form becomes visible. When you have this in the Form Load you are asking VB to set focus to a control that is not visible. That will generate an error.Quote:
Originally Posted by matrik02
While setting the tabindex is the easiest way to ensure a control has the focus when a form is loaded, if you must set the focus using code, then place the line of code in the Form_Activate event. This will do the trick without causing an error.