The distance (in pixels) between the right edge of the RichTextBox control and the right edge of the text that is selected or added at the current insertion point.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
If no text is currently selected, the indentation setting is applied to the paragraph in which the insertion point appears and to all text that is typed into the control after the insertion point. The indentation setting applies until the property is changed to a different value or until the insertion point is moved to a different paragraph within the control.
If text is selected within the control, the selected text and any text entered after the text selection will have the value of this property applied to it. You can use this property to indent paragraphs contained in document of the RichTextBox. You can use this property in conjunction with the SelectionIndent to create paragraphs displayed in paragraphs.
To create a hanging indent for paragraphs in the control, use the SelectionHangingIndent property.
The following code example demonstrates how to create a right margin in a RichTextBox using the property. The example requires that you have a form that contains a RichTextBox control named richTextBox1, and that the example code is called from an event within the form's class.
Private Sub WriteIndentedTextToRichTextBox() ' Clear all text from the RichTextBox; RichTextBox1.Clear() ' Set the font for the text. RichTextBox1.Font = New Font("Lucinda Console", 12) ' Specify a 20 pixel right indent in all paragraphs. RichTextBox1.SelectionRightIndent = 20 ' Set the text within the control. RichTextBox1.SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox." RichTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins." RichTextBox1.SelectedText = "After this paragraph the indentation will end." + ControlChars.CrLf ' Remove all right indentation. RichTextBox1.SelectionRightIndent = 0 RichTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal." End Sub
Available since 1.1