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

RichTextBox.SelectionRightIndent Property

The distance (in pixels) between the right edge of the RichTextBox control and the right edge of the text that is selected or added at the current insertion point.

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

Property Value

The indentation space, in pixels, at the right of the current selection or insertion point.

Remarks

If no text is currently selected, the indentation setting 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 indentation 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 indent paragraphs contained in document of the RichTextBox. You can use this property in conjunction with the SelectionIndent to create paragraphs displayed in paragraphs.

To create a hanging indent for paragraphs in the control, use the SelectionHangingIndent property.

Example

[Visual Basic, C#, C++] The following example demonstrates how to create a right margin in a RichTextBox using the SelectionRightIndent property. The example assumes that you have a form that contains a RichTextBox control named richTextBox1, and that the example code is called from an event within the form's class.

[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 right indent in all paragraphs.
   RichTextBox1.SelectionRightIndent = 30
   ' Set the text within the control.
   RichTextBox1.SelectedText = "All text is indented 20 pixels from the right edge of the RichTextBox."
   RichTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins."
   RichTextBox1.SelectedText = "After this paragraph the indentation will end." + ControlChars.CrLf
   ' Remove all right indentation.
   RichTextBox1.SelectionRightIndent = 0
   RichTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal."
End Sub

[C#] 
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1.SelectionRightIndent = 30;
    // 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 right edge of the RichTextBox.";
    richTextBox1.SelectedText = "You can use this property with the SelectionIndent property to provide right and left margins.";
    richTextBox1.SelectedText = "After this paragraph the indentation will end.\n\n";
    // Remove all right indentation.
    richTextBox1.SelectionRightIndent = 0;
    richTextBox1.SelectedText = "This paragraph has no right indentation. All text should flow as normal.";
}

[C++] 
private:
    void WriteIndentedTextToRichTextBox()
    {
        // Clear all text from the RichTextBox;
        richTextBox1->Clear();
        // Specify a 20 pixel right indent in all paragraphs.
        richTextBox1->SelectionRightIndent = 30;
        // 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"All text is indented 20 pixels from the right edge of the RichTextBox.";
        richTextBox1->SelectedText = S"You can use this property with the SelectionIndent property to provide right and left margins.";
        richTextBox1->SelectedText = S"After this paragraph the indentation will end.\n\n";
        // Remove all right indentation.
        richTextBox1->SelectionRightIndent = 0;
        richTextBox1->SelectedText = S"This paragraph has no right indentation. All text should flow as normal.";
    }

[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

Microsoft sta conducendo un sondaggio in linea per comprendere l'opinione degli utenti in merito al sito Web di MSDN. Se si sceglie di partecipare, quando si lascia il sito Web di MSDN verrà visualizzato il sondaggio in linea.

Si desidera partecipare?
Mostra:
© 2015 Microsoft