Share via


RichTextBox.SelectionRightIndent 属性

RichTextBox 控件右边缘与选中文本或在当前插入点添加的文本的右边缘之间的距离(以像素为单位)。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property SelectionRightIndent As Integer
用法
Dim instance As RichTextBox
Dim value As Integer

value = instance.SelectionRightIndent

instance.SelectionRightIndent = value
public int SelectionRightIndent { get; set; }
public:
property int SelectionRightIndent {
    int get ();
    void set (int value);
}
/** @property */
public int get_SelectionRightIndent ()

/** @property */
public void set_SelectionRightIndent (int value)
public function get SelectionRightIndent () : int

public function set SelectionRightIndent (value : int)

属性值

当前选定内容或插入点右侧的缩进空间(以像素为单位)。

备注

如果当前未选定任何文本,则缩进设置应用到插入点所在段落和在此插入点后键入到控件中的所有文本。缩进设置一直应用到此属性更改为其他值或插入点移动到控件内的其他段落为止。

如果控件内已选定文本,则选定文本和在选定文本之后输入的任何文本都将应用此属性值。可以使用此属性缩进 RichTextBox 的文档中包含的段落。可以将此属性与 SelectionIndent 一起使用以创建显示在段落中的段落。

若要为控件中的段落创建悬挂缩进,请使用 SelectionHangingIndent 属性。

示例

下面的代码示例演示如何使用 SelectionRightIndent 属性在 RichTextBox 中创建右边距。该示例要求您有一个包含名为 richTextBox1RichTextBox 控件的窗体,并且该示例代码由该窗体的类中的某事件调用。

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
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:
   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.set_SelectionRightIndent(20);
    // Set the font for the text.
    richTextBox1.set_Font(new Font("Lucinda Console", 12));
    // Set the text within the control.
    richTextBox1.set_SelectedText("All text is indented 20 pixels from the "
        + "right edge of the RichTextBox.");
    richTextBox1.set_SelectedText("You can use this property with the "
        + "SelectionIndent property to provide right and left margins.");
    richTextBox1.set_SelectedText("After this paragraph the indentation "
        + "will end.\n\n");
    // Remove all right indentation.
    richTextBox1.set_SelectionRightIndent(0);
    richTextBox1.set_SelectedText("This paragraph has no right indentation."
        + "All text should flow as normal.");
} //WriteIndentedTextToRichTextBox

平台

Windows 98、Windows 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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

RichTextBox 类
RichTextBox 成员
System.Windows.Forms 命名空间