Esporta (0) Stampa
Espandi tutto
EN
Il contenuto non è disponibile nella lingua di destinazione, ma solo in inglese.

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.

[Visual Basic]
Public Property SelectionHangingIndent As Integer
[C#]
public int SelectionHangingIndent {get; set;}
[C++]
public: __property int get_SelectionHangingIndent();
public: __property void set_SelectionHangingIndent(int);
[JScript]
public function get SelectionHangingIndent() : int;
public function set SelectionHangingIndent(int);

Property Value

The distance, in pixels, for the hanging indent applied to the current text selection or the insertion point.

Remarks

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.

To set the indention of the first line of a paragraph selection, use the SelectionIndent property.

Example

[Visual Basic, C#, C++] The following example demonstrates how to specify hanging indents within the RichTextBox using the SelectionHangingIndent property. This example assumes that a RichTextBox control, named richTextBox1, has been added to the form.

[Visual Basic] 
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

[C#] 
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.";
}

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RichTextBox Class | RichTextBox Members | System.Windows.Forms Namespace | SelectionIndent

Mostra:
© 2014 Microsoft