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 的每個字元在其自己的行上顯示的位置。 在這個垂直顯示位置中,按一下單字的任何部分將會選取單字的所有字元,而不論文字是垂直顯示。 此範例需要您有一個表單,其中包含 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 為 ,則選取控制項中文字的任何部分會選取整個文字。

適用於