TextBoxBase.SelectAll メソッド

定義

テキスト ボックスのすべてのテキストを選択します。

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

次のコード例では、派生クラスを使用 TextBoxして、コントロールでテキストが選択されているかどうかを判断します。 テキストが選択されていない場合は、コントロールの内容を SelectAll クリップボードにコピーする前に、メソッドを呼び出 します。 この例では、名前が付けられた textBox1a TextBox が作成されている必要があります。

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

注釈

このメソッドを使用すると、コントロール内のすべてのテキストを選択できます。 このメソッドは、コントロール内でテキストを Cut 選択する必要があるメソッドと組み合わせて使用して、コントロールの内容全体を切り取り、 クリップボード に貼り付けることができます。

適用対象