Export (0) Print
Expand All

RichTextBox.RightMargin Property

Gets or sets the size of a single line of text within the RichTextBox control.

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

member RightMargin : int with get, set

Property Value

Type: System.Int32
The size, in pixels, of a single line of text in the control. The default is zero.

ExceptionCondition
ArgumentException

The specified value was less than zero.

When a value greater than zero is entered into the control, a nonvisible margin is placed in the control at the specified number of pixels from the left side of the control. Any text that is entered that extends beyond this margin is placed on the next line of text in the control. This property affects all text currently entered into the control as well as any additional text entered into the control after the property is set. You can use this property to specify a maximum line width for all text entered into a RichTextBox control.

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.

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft