Link to home
Start Free TrialLog in
Avatar of RobertoFreemano
RobertoFreemanoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

set cursor focus in a textbox.text on lauch app (winform) vb.net 2008

Hi Experts,

I want to set the cursor focus in a textbox.text when I open the winform in run-time.

I've tried Textbox.focus, but this doesn't appear to work.

Cheers,
Roberto
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Hello RobertoFreemano,

Try : myTextbox.Focus()

Source : http://msdn.microsoft.com/en-us/library/ms743469.aspx

Regards.
Avatar of RobertoFreemano

ASKER

Hi leakim971,

Sadly, this did not work :(

Cheers,
Roberto
Please post your code if possible.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.TextBox1.Focus()

End Sub
I've also set the tabIndex = 0
TabIndex should be the way to do it...is this the "startup form" or are you opening it from another one?

Perhaps something else is interfering?  Do you have any third party controls in the application?
ASKER CERTIFIED SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Idle Mind,

This is the process:

1. Form 1 = startup
2. form 1 runs splash screen form 2 for xx seconds before returning to form 1
3. form 2 has 2 buttons. if button 1 is clicked, it hides form 1 and runs form 3
4. Form 3 opens and this is were I want the focus to appear in textbox1.text

Hope this helps
P.s. I don't think I have any 3rd Party controls in the app.

Thanks,
Roberto
Oops- amended

Hi Idle Mind,

This is the process:

1. Form 1 = startup
2. form 1 runs splash screen form 2 for xx seconds before returning to form 1
3. form 1 has 2 buttons. if button 1 is clicked, it hides form 1 and runs form 3
4. Form 3 opens and this is were I want the focus to appear in textbox1.text

Hope this helps
P.s. I don't think I have any 3rd Party controls in the app.

Thanks,
Roberto
Hi hnasr,

I tried your suggestion,  and it worked.

Many thanks,

Roberto
Thanks hnasr
Can you show us the Button1 code where you open Form3 and hide Form1?
Welcome!