selecting text in a textbox

  • Thread starter Thread starter John Baro
  • Start date Start date
J

John Baro

I have a textbox where I wish the text to be selected when the user clicks
on the textbox.

Textbox.SelectAll();

or

Textbox.SelectionStart = 0;
Textbox.SelectionLength = Textbox.Text.Length;

Neither work if the user clicks.
Both work if the user tabs
or I set focus in code.

:(

JB
The greatest arrogance of humankind was to believe they were unique.
 
John said:
I have a textbox where I wish the text to be selected when the user clicks
on the textbox.

Textbox.SelectAll();

<snip>

Try this:

textBox_MouseUp(...)
{
textBox.SelectAll();
}

That should fix the whole problem for you, since "tabbing" to a text box
automatically selects all the text.
 
Love your work CSL.
Thanks
JB
C# Learner said:
<snip>

Try this:

textBox_MouseUp(...)
{
textBox.SelectAll();
}

That should fix the whole problem for you, since "tabbing" to a text box
automatically selects all the text.
 
Back
Top