RichTextBox.SelectionHangingIndent RichTextBox.SelectionHangingIndent RichTextBox.SelectionHangingIndent RichTextBox.SelectionHangingIndent Property

定义

获取或设置选定段落中第一行文本的左边缘和同一段落中后面各行的左边缘之间的距离。Gets or sets the distance between the left edge of the first line of text in the selected paragraph and the left edge of subsequent lines in the same paragraph.

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

属性值

应用到当前选定文本或插入点的悬挂缩进的距离(以像素为单位)。The distance, in pixels, for the hanging indent applied to the current text selection or the insertion point.

示例

下面的代码示例演示如何RichTextBox SelectionHangingIndent使用属性在中指定悬挂缩进。The following code example demonstrates how to specify hanging indents within the RichTextBox using the SelectionHangingIndent property. 此示例要求RichTextBox已将名为richTextBox1的控件添加到窗体中。This example requires that a RichTextBox control, named richTextBox1, has been added to the form.

private:
   void WriteIndentedTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Specify a 20 pixel hanging indent in all paragraphs.
      richTextBox1->SelectionHangingIndent = 20;

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

      // Set the text within the control.
      richTextBox1->SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
      richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
      richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
      richTextBox1->SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
      richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
   }
private void WriteIndentedTextToRichTextBox()
{
   // Clear all text from the RichTextBox;
   richTextBox1.Clear();
   // Specify a 20 pixel hanging indent in all paragraphs.
   richTextBox1.SelectionHangingIndent = 20;
   // Set the font for the text.
   richTextBox1.Font = new Font("Lucinda Console", 12);
   // Set the text within the control.
   richTextBox1.SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
   richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
   richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
   richTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
   richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
}
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 hanging indent in all paragraphs.
   RichTextBox1.SelectionHangingIndent = 20
   ' Set the text within the control.
   RichTextBox1.SelectedText = "VBThis text contains a hanging indent. The first sentence of the paragraph is spaced normally."
   RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
   RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.CrLf
   RichTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph."
   RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
End Sub

注解

如果当前未选择任何文本,则悬挂缩进将应用于插入点所在的段落以及插入点之后键入到控件中的所有文本。If no text is currently selected, the hanging indent 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 hanging indent 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 apply a hanging indent to your paragraphs.

若要设置段落选择的第一行的缩进,请使用SelectionIndent属性。To set the indention of the first line of a paragraph selection, use the SelectionIndent property.

适用于

另请参阅