|
-
Jun 5th, 2007, 06:29 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] SetFocus on a text box?
Hi all,
How do you set focus on a text box programiticaly in vb.net 2005?
-
Jun 5th, 2007, 06:33 AM
#2
Frenzied Member
Re: [2005] SetFocus on a text box?
-
Jun 5th, 2007, 06:40 AM
#3
Thread Starter
Addicted Member
Re: [2005] SetFocus on a text box?
Hi robertx,
How do I set focus on a text box and also highlight the text within it?
-
Jun 5th, 2007, 06:41 AM
#4
Frenzied Member
Re: [2005] SetFocus on a text box?
TextBox1.Focus
TextBox1.SelectAll
-
Jun 5th, 2007, 06:48 AM
#5
Thread Starter
Addicted Member
Re: [2005] SetFocus on a text box?
excellent, thank you for you help.
-
Jun 5th, 2007, 08:13 AM
#6
Re: [RESOLVED] [2005] SetFocus on a text box?
This is from the MSDN help topic for the Control.Focus method:
Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.
-
Jun 5th, 2007, 08:24 AM
#7
Re: [2005] SetFocus on a text box?
 Originally Posted by Giraffe Frenzy
Hi robertx,
How do I set focus on a text box and also highlight the text within it?
It just so happens I posted an article about this yesterday. There is a little .NET event order quirk that you have to be aware of when selecting text in code. That is you must put your SelectAll code in both the Enter and MouseDown events of the control. If you don't, the mouse click will change your selection. This is different than the way VB6 behaved so watch out for it.
-
Jun 12th, 2007, 07:58 PM
#8
Re: [2005] SetFocus on a text box?
 Originally Posted by bgmacaw
It just so happens I posted an article about this yesterday. There is a little .NET event order quirk that you have to be aware of when selecting text in code. That is you must put your SelectAll code in both the Enter and MouseDown events of the control. If you don't, the mouse click will change your selection. This is different than the way VB6 behaved so watch out for it.
Was searching for this exact answer wondering why clicking in my text box didn't fire the Enter event. Thanks for the post!
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
|