Export (0) Print
Expand All

RichTextBox.AutoWordSelection Property

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

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public bool AutoWordSelection { get; set; }
/** @property */
public boolean get_AutoWordSelection ()

/** @property */
public void set_AutoWordSelection (boolean value)

public function get AutoWordSelection () : boolean

public function set AutoWordSelection (value : boolean)

Not applicable.

Property Value

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

If this property is set to true, selecting any part of the text in the control selects the entire word.

The following code 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 requires that you have a form that contains a RichTextBox control named 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.set_AutoWordSelection(true);
    // Clear contents of control.
    richTextBox1.Clear();
    // Set the right margin to restrict horizontal text.
    richTextBox1.set_RightMargin(2);
    // Set the text for the control.
    richTextBox1.set_SelectedText("Alpha Bravo Charlie Delta Echo Foxtrot");
    // Zoom by 2 points.
    richTextBox1.set_ZoomFactor(2);
} //ZoomMyRichTextBox

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft