Поделиться через


RichTextBox.SelectionIndent Свойство

Определение

Возвращает или задает длину (в пикселях) отступа строки, в которой начинается выделение.

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

Значение свойства

Текущее расстояние (в пикселях) отступа, примененное слева от текущего выделения текста или точки вставки.

Атрибуты

Примеры

В следующем примере кода показано, как указать отступный текст в свойстве RichTextBoxSelectionIndent . В этом примере требуется, чтобы RichTextBox элемент управления с именем richTextBox1был добавлен в форму.

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

      // Specify a 20 pixel indent in all paragraphs.
      richTextBox1->SelectionIndent = 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 left edge of the RichTextBox.";
      richTextBox1->SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
      richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
      richTextBox1->SelectionIndent = 0;
      richTextBox1->SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel indent in all paragraphs.
    richTextBox1.SelectionIndent = 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 left edge of the RichTextBox.";
    richTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
    richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
    richTextBox1.SelectionIndent = 0;
    richTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
}
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 indent in all paragraphs.
   RichTextBox1.SelectionIndent = 20
   ' Set the text within the control.
   RichTextBox1.SelectedText = "All text is indented 20 pixels from the left edge of the RichTextBox."
   RichTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter."
   RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.Crlf
   RichTextBox1.SelectionIndent = 0
   RichTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge."
End Sub

Комментарии

Если в данный момент текст не выбран, параметр отступа применяется к абзацу, в котором отображается точка вставки, и ко всему тексту, который вводится в элемент управления после точки вставки. Параметр отступа применяется, пока свойство не будет изменено на другое значение или пока точка вставки не будет перемещена в другой абзац в элементе управления.

Если текст выбран в элементе управления, выделенный текст и любой текст, введенный после выделения текста, будет иметь значение этого свойства, примененного к нему. Это свойство можно использовать для отступа абзацев, содержащихся в документе RichTextBox. Это свойство можно использовать в сочетании с SelectionRightIndent абзацами, отображаемыми в абзацах.

Чтобы создать зависающую отступ для абзацев в элементе управления, используйте SelectionHangingIndent свойство.

Применяется к

См. также раздел