語言

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

屬性值

true若啟用自動單字選擇;否則,。 false 預設值為 true。

範例

以下程式碼範例示範如何建立 RichTextBox 一個能放大文字、雙擊字詞時自動選取控制項文字中的字詞,並在控制項客戶端右側有邊界。 如果控制 RichTextBox 鍵寬度較小,使用此程式碼會產生 RichTextBox 一個字元顯示在獨立行的欄位。 在此垂直顯示位置時,點擊單字的任何部分,無論文字是否垂直顯示,都會選取該單字的所有字元。 這個範例要求你有一個包含 RichTextBox 名為 richTextBox1的控制項的表單。

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,選取控制項中任一部分即可選取整個單字。

適用於