Freigeben über


RichTextBox.SelectionHangingIndent-Eigenschaft

Ruft den Abstand zwischen dem linken Rand der ersten Textzeile des markierten Absatzes und dem linken Rand nachfolgender Zeilen in demselben Absatz ab oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property SelectionHangingIndent As Integer
'Usage
Dim instance As RichTextBox
Dim value As Integer

value = instance.SelectionHangingIndent

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

/** @property */
public void set_SelectionHangingIndent (int value)
public function get SelectionHangingIndent () : int

public function set SelectionHangingIndent (value : int)

Eigenschaftenwert

Der Abstand für den hängenden Einzug, der auf die aktuelle Textauswahl oder Einfügemarke angewendet wird (in Pixel).

Hinweise

Wenn derzeit kein Text markiert ist, wird der hängende Einzug auf den Absatz angewendet, in dem sich die aktuelle Einfügemarke befindet, sowie auf sämtlichen nach der Einfügemarke in das Steuerelement eingegebenen Text. Die Einstellung für hängenden Einzug wird angewendet, bis die Eigenschaft auf einen anderen Wert geändert oder die Einfügemarke in einen anderen Abschnitt des Steuerelements verschoben wird.

Wenn Text im Steuerelement markiert ist, wird auf diesen und sämtlichen danach eingegebenen Text der Wert dieser Eigenschaft angewendet. Mit dieser Eigenschaft können Sie auf die Absätze einen hängenden Einzug anwenden.

Um den Einzug der ersten Zeile eines markierten Absatzes festzulegen, verwenden Sie die SelectionIndent-Eigenschaft.

Beispiel

Im folgenden Codebeispiel wird die Verwendung der SelectionHangingIndent-Eigenschaft zum Angeben von hängenden Einzügen in der RichTextBox veranschaulicht. Für dieses Beispiel ist es erforderlich, dass dem Formular ein RichTextBox-Steuerelement mit dem Namen richTextBox1 hinzugefügt wurde.

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
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:
   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.set_SelectionHangingIndent(20);
    // Set the font for the text.
    richTextBox1.set_Font(new Font("Lucinda Console", 12));
    // Set the text within the control.
    richTextBox1.set_SelectedText("This text contains a hanging indent."
        + "The first sentence of the paragraph is spaced normally.");
    richTextBox1.set_SelectedText("All subsequent lines of text are "
        + "indented based on the value of SelectionHangingIndent.");
    richTextBox1.set_SelectedText("After this paragraph the indent is "
        + "returned to normal spacing.\n");
    richTextBox1.set_SelectedText("Since this is a new paragraph the indent"
        + "is also applied to this paragraph.");
    richTextBox1.set_SelectedText("All subsequent lines of text are "
        + "indented based on the value of SelectionHangingIndent.");
} //WriteIndentedTextToRichTextBox

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

RichTextBox-Klasse
RichTextBox-Member
System.Windows.Forms-Namespace
SelectionIndent