Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RichTextBox.AutoWordSelection Property

Gets or sets a value indicating whether automatic word selection is enabled.

[Visual Basic]
Public Property AutoWordSelection As Boolean
[C#]
public bool AutoWordSelection {get; set;}
[C++]
public: __property bool get_AutoWordSelection();
public: __property void set_AutoWordSelection(bool);
[JScript]
public function get AutoWordSelection() : Boolean;
public function set AutoWordSelection(Boolean);

Property Value

true if automatic word selection is enabled; otherwise, false. The default is false.

Remarks

If this property is set to true, selecting any part of the text in the control results in the selection of the entire word. For example, if AutoWordSelection is set to true, the user can double-click on any part of a word in the control and the entire word is selected automatically.

Example

[Visual Basic, C#, C++] The following example demonstrates how to create a RichTextBox that zooms in on text, automatically selects words in the text of the control when a word is double clicked, and has a margin on the right side of the client area of the control. If the RichTextBox control has a small width, using this code will create a RichTextBox where each character of text is displayed on its own line. While in this vertical display position, clicking on any part of a word will select all characters of the word regardless of the fact that the text is displayed vertically. This example assumes that you have a form that contains a RichTextBox control named richTextBox1.

[Visual Basic] 
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

[C#] 
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;
}

[C++] 
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 = S"Alpha Bravo Charlie Delta Echo Foxtrot";
        // Zoom by 2 points.
        richTextBox1->ZoomFactor = 2.0f;
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RichTextBox Class | RichTextBox Members | System.Windows.Forms Namespace

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft