TextBoxBase.SelectAll Méthode

Définition

Sélectionne tout le texte dans la zone de texte.

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

Exemples

L’exemple de code suivant utilise TextBox, une classe dérivée, pour déterminer si un texte est sélectionné dans le contrôle. Si aucun texte n’est sélectionné, un appel est effectué à la SelectAll méthode avant de copier le contenu du contrôle dans le Presse-papiers. Cet exemple nécessite qu’un TextBox a été créé nommé 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

Remarques

Cette méthode vous permet de sélectionner tout le texte dans le contrôle. Vous pouvez utiliser cette méthode conjointement avec la Cut méthode, qui nécessite que le texte soit sélectionné dans le contrôle, pour couper l’intégralité du contenu du contrôle et les coller dans le Presse-papiers.

S’applique à