RichTextBox.AutoWordSelection プロパティ

定義

単語の自動選択を有効にするかどうかを示す値を取得または設定します。

public:
 property bool AutoWordSelection { bool get(); void set(bool value); };
public bool AutoWordSelection { get; set; }
member this.AutoWordSelection : bool with get, set
Public Property AutoWordSelection As Boolean

プロパティ値

Boolean

単語の自動選択が有効な場合は true。それ以外の場合は false。 既定値は、true です。

次のコード例では、テキストを RichTextBox 拡大し、単語がダブルクリックされたときにコントロールのテキスト内の単語を自動的に選択し、コントロールのクライアント領域の右側に余白を設定する方法を示します。 コントロールの RichTextBox 幅が小さい場合、このコードを使用すると、テキストの各文字が独自の行に表示される場所が作成 RichTextBox されます。 この垂直方向の表示位置では、単語の任意の部分をクリックすると、テキストが垂直方向に表示されるという事実に関係なく、単語のすべての文字が選択されます。 この例では、という名前richTextBox1のコントロールを含むRichTextBoxフォームが必要です。

private:
   void ZoomMyRichTextBox()
   {
      // Enable users to select entire word when double clicked.
      richTextBox1->AutoWordSelection = true;

      // Clear contents of control.
      richTextBox1->Clear();

      // Set the right margin to restrict horizontal text.
      richTextBox1->RightMargin = 2;

      // Set the text for the control.
      richTextBox1->SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";

      // Zoom by 2 points.
      richTextBox1->ZoomFactor = 2.0f;
   }
private void ZoomMyRichTextBox()
{
    // Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = true;
    // Clear contents of control.
    richTextBox1.Clear();
    // Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2;
    // Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";
    // Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0f;
}
Private Sub ZoomMyRichTextBox()
    ' Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = True
    ' Clear contents of control.
    richTextBox1.Clear()
    ' Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2
    ' Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot"
    ' Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0F
End Sub

注釈

このプロパティが true設定されている場合は、コントロール内のテキストの任意の部分を選択すると、単語全体が選択されます。

適用対象