TextBoxBase.SelectAll メソッド

定義

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

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

次のコード例では、派生クラス TextBoxを使用して、コントロールでテキストが選択されているかどうかを判断します。 テキストが選択されていない場合は、コントロールの内容をクリップボードにコピーする前に、 SelectAll メソッドを呼び出 します。 この例では、textBox1という名前の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 メソッドと組み合わせて使用して、コントロールの内容全体を切り取り、 クリップボードに貼り付けることができます。

適用対象