RichTextBox.SelectionRightIndent RichTextBox.SelectionRightIndent RichTextBox.SelectionRightIndent RichTextBox.SelectionRightIndent Property

定义

RichTextBox 控件右边缘与选中文本或在当前插入点添加的文本的右边缘之间的距离(以像素为单位)。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.

public:
 property int SelectionRightIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionRightIndent { get; set; }
member this.SelectionRightIndent : int with get, set
Public Property SelectionRightIndent As Integer

属性值

当前选定内容或插入点右侧的缩进空间(以像素为单位)。The indentation space, in pixels, at the right of the current selection or insertion point.

示例

下面的代码示例演示如何RichTextBox SelectionRightIndent使用属性在中创建右边缘。The following code example demonstrates how to create a right margin in a RichTextBox using the SelectionRightIndent property. 该示例要求您具有一个包含RichTextBox名为richTextBox1的控件的窗体,并且该示例代码是从窗体的类中的事件调用的。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:
   void WriteIndentedTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1->SelectionRightIndent = 20;

      // Set the font for the text.
      richTextBox1->Font = gcnew System::Drawing::Font( "Lucinda Console",12 );

      // 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.\n\n";

      // Remove all right indentation.
      richTextBox1->SelectionRightIndent = 0;
      richTextBox1->SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
    richTextBox1.SelectionRightIndent = 20;
    // Set the font for the text.
    richTextBox1.Font = new Font("Lucinda Console", 12);
    // 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.\n\n";
    // Remove all right indentation.
    richTextBox1.SelectionRightIndent = 0;
    richTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
}
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

注解

如果当前未选择任何文本,则缩进设置将应用于插入点所在的段落以及插入点之后键入到控件中的所有文本。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. 您可以使用此属性缩进文档RichTextBox中包含的段落。You can use this property to indent paragraphs contained in document of the RichTextBox. 可以将此属性与SelectionIndent一起使用,以创建在段落中显示的段落。You can use this property in conjunction with the SelectionIndent to create paragraphs displayed in paragraphs.

若要为控件中的段落创建悬挂缩进,请SelectionHangingIndent使用属性。To create a hanging indent for paragraphs in the control, use the SelectionHangingIndent property.

适用于