Hi all,
How do you set focus on a text box programiticaly in vb.net 2005?
Printable View
Hi all,
How do you set focus on a text box programiticaly in vb.net 2005?
TextBox1.Focus
Hi robertx,
How do I set focus on a text box and also highlight the text within it?
TextBox1.Focus
TextBox1.SelectAll
excellent, thank you for you help.
This is from the MSDN help topic for the Control.Focus method:Quote:
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.
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.Quote:
Originally Posted by Giraffe Frenzy
Was searching for this exact answer wondering why clicking in my text box didn't fire the Enter event. Thanks for the post! :DQuote:
Originally Posted by bgmacaw