RichTextBox.SelectionRightIndent 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
RichTextBox 控件右边缘与选中文本或在当前插入点添加的文本的右边缘之间的距离(以像素为单位)。
public:
property int SelectionRightIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionRightIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionRightIndent : int with get, set
Public Property SelectionRightIndent As Integer
属性值
当前选定内容或插入点右侧的缩进空间(以像素为单位)。
- 属性
示例
下面的代码示例演示如何在使用SelectionRightIndent属性中创建RichTextBox右边距。 该示例要求你有一个包含 RichTextBox 命名 richTextBox1
控件的窗体,并且示例代码是从窗体类中的事件调用的。
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
注解
如果当前未选择任何文本,则缩进设置将应用于插入点出现的段落以及插入点后键入控件的所有文本。 缩进设置适用于将属性更改为其他值,或者直到插入点移动到控件中的另一个段落为止。
如果在控件中选择文本,则所选文本和在文本选择后输入的任何文本都将应用此属性的值。 可以使用此属性缩进文档 RichTextBox中包含的段落。 可以将此属性与创建段落中显示的段落结合使用 SelectionIndent 。
若要为控件中的段落创建悬挂缩进,请使用该 SelectionHangingIndent 属性。