Düzenle

Aracılığıyla paylaş


TextBoxBase.SelectAll Method

Definition

Selects all text in the text box.

public:
 void SelectAll();
public void SelectAll ();
member this.SelectAll : unit -> unit
Public Sub SelectAll ()

Examples

The following code 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 requires that a TextBox has been created named textBox1.

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();
   }
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();
 }
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

Remarks

This method enables you to select all text within the control. You can use this method in conjunction 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.

Applies to