Freigeben über


TextBoxBase.SelectAll-Methode

Markiert den gesamten Text im Textfeld.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Sub SelectAll
'Usage
Dim instance As TextBoxBase

instance.SelectAll
public void SelectAll ()
public:
void SelectAll ()
public void SelectAll ()
public function SelectAll ()

Hinweise

Mit dieser Methode können Sie Text im Steuerelement markieren. Sie können diese Methode zusammen mit der Cut-Methode verwenden, für die Text im Steuerelement markiert sein muss, um den gesamten Inhalt des Steuerelements auszuschneiden und in die Zwischenablage zu kopieren.

Beispiel

Im folgenden Codebeispiel wird mit der abgeleiteten Klasse TextBox bestimmt, ob im Steuerelement Text markiert ist. Wenn kein Text markiert ist, wird die SelectAll-Methode aufgerufen, bevor der Inhalt des Steuerelements in die Zwischenablage kopiert wird. In diesem Beispiel ist es erforderlich, dass eine TextBox mit dem Namen textBox1 erstellt wurde.

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
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 void CopyAllMyText()
{
    // Determine if any text is selected in the TextBox control.
    if (textBox1.get_SelectionLength() == 0) {
        // Select all text in the text box.
        textBox1.SelectAll();
    }
    // Copy the contents of the control to the Clipboard.
    textBox1.Copy();
} //CopyAllMyText

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

TextBoxBase-Klasse
TextBoxBase-Member
System.Windows.Forms-Namespace