|
-
May 11th, 2007, 03:25 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] set focus problem
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..
-
May 11th, 2007, 03:29 AM
#2
Re: set focus problem
During design time make the TabIndex Property of Text1 to 0.
-
May 11th, 2007, 03:38 AM
#3
Thread Starter
Frenzied Member
Re: set focus problem
Thank you so much so simple..
-
May 11th, 2007, 03:39 AM
#4
Re: set focus problem
No problem. You can now mark this thread resolved. Thanks!
-
May 11th, 2007, 07:52 AM
#5
Re: [RESOLVED] set focus problem
 Originally Posted by matrik02
text1.setfocus but I got the error.. 
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.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|