Textbox focus

  • Thread starter Thread starter toysrwill
  • Start date Start date
T

toysrwill

I am trying to create a program where the textbox will always have
focus regardless of buttons pressed or other events. However when I do
a simple textBox1.Focus() it highlights the data in the textbox. I do
not want the text highlighted,but I always want the textbox with the
focus.
Thanks in Advance
 
Hi toysrwill

After the textBox1.Focus() line, put

textBox1.SelectionStart = textBox1.TextLength;

Happy coding!
Morten Wennevik [C# MVP]
 
* (e-mail address removed) (toysrwill) scripsit:
I am trying to create a program where the textbox will always have
focus regardless of buttons pressed or other events. However when I do
a simple textBox1.Focus() it highlights the data in the textbox. I do
not want the text highlighted,but I always want the textbox with the
focus.

Have a look at the textbox's overloaded 'Select' method and call
'Me.TextBox1.Select(0, 0)'.
 
Back
Top