RichTextBox.SelectionHangingIndent Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Получает или задает расстояние между левым краем первой строки текста в выбранном абзаце и левым краем последующих строк в том же абзаце.
public:
property int SelectionHangingIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionHangingIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionHangingIndent : int with get, set
Public Property SelectionHangingIndent As Integer
Значение свойства
Расстояние (в пикселях) для отступа, примененного к текущему выделенному тексту или точке вставки.
- Атрибуты
Примеры
В следующем примере кода показано, как указать висящие отступы в пределах RichTextBox свойства SelectionHangingIndent . В этом примере требуется, чтобы RichTextBox элемент управления с именем richTextBox1был добавлен в форму.
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
Комментарии
Если в данный момент текст не выбран, отступ висит к абзацу, в котором отображается точка вставки, и ко всему тексту, который вводится в элемент управления после точки вставки. Параметр отступа применяется, пока свойство не будет изменено на другое значение или пока точка вставки не будет перемещена в другой абзац в элементе управления.
Если текст выбран в элементе управления, выделенный текст и любой текст, введенный после выделения текста, будет иметь значение этого свойства, примененного к нему. Это свойство можно использовать для применения зависания отступа к абзацам.
Чтобы задать отступ первой строки выделения абзаца, используйте SelectionIndent свойство.