user34537
user34537

Reputation:

How does one select all text in a Windows Forms TextBox?

How do I allow select all in my multi-lined TextBox?

It seems weird to me that there would not be a way to do this; there should be something in the framework out of the box.

Upvotes: 2

Views: 2344

Answers (3)

TheVillageIdiot
TheVillageIdiot

Reputation: 40497

How about textbox1.SelectAll()?

You can also use

textbox1..Select(0, textbox1.Text.Length);

and turn property HideSelection to False.

Upvotes: 0

olle
olle

Reputation: 4595

In case of Windows Forms:

textbox.SelectAll();

Upvotes: 9

JaredPar
JaredPar

Reputation: 754545

Try the SelectAll method (actually located on TextBoxBase).

TextBoxBase b = GetTheTextBox();
b.SelectAll();

Upvotes: 1

Related Questions