Autoselect textbox contet

R

Rafael Pivato

How can I autoselect a TextBox text when the user taps it ?

I tried handling the GotFocus event and using SelectAll function, but the
text selects and deselects...
 
A

Alex Feinman [MVP]

Set a short one-shot timer in GotFocus event - something like 100-200 ms
would do. On timer event select all text.
 
G

Ginny Caughey [MVP]

Rafael,

I was never able to get SelectAll to do what I wanted either, so I ended up
just setting the textbox Text = "" when it gets focus. That's not the same
thing, of course, but it works the same for my users.
 
R

Rafael Pivato

Thanks Alex!



What coincidence!!! I recently tried id with a thread and invoke as a "last
try". Not to good.

Using the complete framework with a Windows Forms Application it would work
just by this way too?



Alex Feinman said:
Set a short one-shot timer in GotFocus event - something like 100-200 ms
would do. On timer event select all text.
 

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