Select all text in a TextBox

  • Thread starter Thread starter José Manuel \(Computer Xàbia\)
  • Start date Start date
J

José Manuel \(Computer Xàbia\)

Hi,
I need to all text in a TextBox was selected when the user goes into it.
While Click event seems not work, what can I do?

Tanks!
 
I tried with GotFocus event, but if I select text in this event, the last
click message unselect the text.
This is:
1.- User clicks TextBox
2.- GotFocus event executes, and select the text.
3.- System process the click message and unselect the text!

Any suggestions?
 
Now I recall that issue.. from memory the following workaround should do
it:

Add a windows.forms.timer to your form with a very small interval (e.g.
15ms)
in the got focus event: tmr.Enabled = true
in the tick event: tmr.Enabled=false; tb.SelectAll

Cheers
Daniel
 
Back
Top