Textbox focus

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
 
M

Morten Wennevik

Hi toysrwill

After the textBox1.Focus() line, put

textBox1.SelectionStart = textBox1.TextLength;

Happy coding!
Morten Wennevik [C# MVP]
 
H

Herfried K. Wagner [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)'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top