Sdílet prostřednictvím


RichTextBox.SelectionHangingIndent Vlastnost

Definice

Získá nebo nastaví vzdálenost mezi levým okrajem prvního řádku textu ve vybraném odstavci a levým okrajem dalších řádků ve stejném odstavci.

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

Hodnota vlastnosti

Vzdálenost v pixelech pro předsazení použité u aktuálního výběru textu nebo kurzoru.

Atributy

Příklady

Následující příklad kódu ukazuje, jak určit předsazení v rámci RichTextBox použití SelectionHangingIndent vlastnosti. Tento příklad vyžaduje, aby RichTextBox byl do formuláře přidán ovládací prvek s názvem 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

Poznámky

Pokud není aktuálně vybraný žádný text, předsazení se použije u odstavce, ve kterém se kurzor zobrazí, a pro veškerý text zadaný do ovládacího prvku za kurzorem. Nastavení předsazení platí, dokud se vlastnost nezmění na jinou hodnotu nebo dokud se kurzor nepřesune do jiného odstavce v ovládacím prvku.

Pokud je text vybrán v ovládacím prvku, bude mít vybraný text a jakýkoli text zadaný po výběru textu hodnotu této vlastnosti. Pomocí této vlastnosti můžete u odstavců použít předsazení.

Pokud chcete nastavit odsazení prvního řádku výběru odstavce, použijte SelectionIndent tuto vlastnost.

Platí pro

Viz také