Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select all the text within a Windows Forms textbox? [closed]

Tags:

I want to select all the text that is with in text box.

I've tried this using the code below:

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

Source: I got this code from here http://msdn.microsoft.com/en-us/library/vstudio/hk09zy8f(v=vs.100).aspx but for some reason it doesn't seem to work.

like image 697
B. Clay Shannon-B. Crow Raven Avatar asked Aug 05 '13 04:08

B. Clay Shannon-B. Crow Raven


1 Answers

You can use the built in method for this purpose.

textBoxResults.SelectAll(); textBoxResults.Focus(); //you need to call this to show selection if it doesn't has focus 
like image 193
Ehsan Avatar answered Sep 28 '22 01:09

Ehsan