I have the requirement that whenever a TextBox gets Focus (via Touch, Mouse, Keyboard) that all Text should be selected.
I tried with the GotFocus
event and with the OnMouseDown
/OnMouseUp
(for mouse) events:
if (this.SelectionLength == 0)
{
this.Focus();
this.SelectAll();
}
but this is not working in all cases.
Sometimes I need to click twice into a TextBox, sometimes not.
Is the a definitive answer here?