RichTextBox.SelectionLength Property


Gets or sets the number of characters selected in control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

override SelectionLength : int with get, set

Property Value

Type: System.Int32

The number of characters selected in the text box.

You can use this property to determine if any characters are currently selected in the text box control before performing operations on the selected text. You can also use this property to determine the total number of characters (including spaces) that are selected when performing single character tasks in a for loop.

The following code example demonstrates how to use the SelectionLength property to determine if text is selected within the RichTextBox. This example requires that a RichTextBox control, named richTextBox1, has been added to the form. The example also requires that richTextBox1 contains text that is selected in the control.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top