Share via


RichTextBox.SelectionRightIndent Propiedad

Definición

Distancia (en píxeles) entre el margen derecho del control RichTextBox y el margen derecho del texto que se selecciona o agrega en el punto de inserción actual.

public:
 property int SelectionRightIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionRightIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionRightIndent : int with get, set
Public Property SelectionRightIndent As Integer

Valor de propiedad

Int32

Espacio de la sangría, en píxeles, a la derecha de la selección o del punto de inserción actual.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo crear un margen derecho en un RichTextBox mediante la SelectionRightIndent propiedad . El ejemplo requiere que tenga un formulario que contenga un RichTextBox control denominado richTextBox1y que se llame al código de ejemplo desde un evento dentro de la clase del formulario.

private:
   void WriteIndentedTextToRichTextBox()
   {
      // Clear all text from the RichTextBox;
      richTextBox1->Clear();

      // Specify a 20 pixel right indent in all paragraphs.
      richTextBox1->SelectionRightIndent = 20;

      // Set the font for the text.
      richTextBox1->Font = gcnew System::Drawing::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.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel right indent in all paragraphs.
    richTextBox1.SelectionRightIndent = 20;
    // 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.";
}
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 = 20
   ' 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

Comentarios

Si no hay texto seleccionado actualmente, la configuración de sangría se aplica al párrafo en el que aparece el punto de inserción y a todo el texto escrito en el control después del punto de inserción. El valor de sangría se aplica hasta que la propiedad cambia a un valor diferente o hasta que el punto de inserción se mueve a un párrafo diferente dentro del control.

Si se selecciona texto dentro del control, el texto seleccionado y cualquier texto escrito después de la selección de texto tendrá aplicado el valor de esta propiedad. Puede usar esta propiedad para sangr los párrafos contenidos en el RichTextBoxdocumento de . Puede usar esta propiedad junto con SelectionIndent para crear párrafos mostrados en párrafos.

Para crear una sangría colgante para los párrafos del control, use la SelectionHangingIndent propiedad .

Se aplica a