Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TextBoxBase.SelectAll Method

Selects all text in the text box.

[Visual Basic]
Public Sub SelectAll()
[C#]
public void SelectAll();
[C++]
public: void SelectAll();
[JScript]
public function SelectAll();

Remarks

This method enables you to select all text within the control. You can use this method inconjunction with the Cut method, which requires text to be selected in the control, to cut the entire contents of the control and paste them into the Clipboard.

Example

[Visual Basic, C#, C++] The following example uses TextBox, a derived class, to determine if any text is selected in the control. If no text is selected, a call is made to the SelectAll method before copying the contents of the control to the Clipboard. This example assumes that a TextBox has been created named textBox1.

[Visual Basic] 
Public Sub CopyAllMyText()
    ' Determine if any text is selected in the TextBox control.
    If textBox1.SelectionLength = 0 Then
        ' Select all text in the text box.
        textBox1.SelectAll()
    End If 
    ' Copy the contents of the control to the Clipboard.
    textBox1.Copy()
End Sub


[C#] 
public void CopyAllMyText()
 {
    // Determine if any text is selected in the TextBox control.
    if(textBox1.SelectionLength == 0)
       // Select all text in the text box.
       textBox1.SelectAll();
    
    // Copy the contents of the control to the Clipboard.
    textBox1.Copy();
 }


[C++] 
public:
void CopyAllMyText()
 {
    // Determine if any text is selected in the TextBox control.
    if(textBox1->SelectionLength == 0)
       // Select all text in the text box.
       textBox1->SelectAll();
    
    // Copy the contents of the control to the Clipboard.
    textBox1->Copy();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

TextBoxBase Class | TextBoxBase Members | System.Windows.Forms Namespace

Show:
© 2015 Microsoft