TextBoxBase.SelectAll Metod

Definition

Markerar all text i textrutan.

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

Exempel

I följande kodexempel används TextBox, en härledd klass, för att avgöra om någon text har valts i kontrollen. Om ingen text har valts görs ett anrop till SelectAll metoden innan innehållet i kontrollen kopieras till Urklipp. Det här exemplet kräver att en TextBox har skapats med namnet 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

Kommentarer

Med den här metoden kan du välja all text i kontrollen. Du kan använda den Cut här metoden tillsammans med metoden, som kräver att text markeras i kontrollen, för att klippa ut hela innehållet i kontrollen och klistra in dem i Urklipp.

Gäller för