RichTextBox.SelectionIndent Propiedad

Definición

Obtiene o establece la longitud, en píxeles, de la sangría de la línea donde se inicia la selección.

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

Valor de propiedad

Int32

Distancia actual, en píxeles, de la sangría que se aplica a la izquierda del texto seleccionado o del punto de inserción.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo especificar texto con sangría dentro de mediante RichTextBox la SelectionIndent propiedad . En este ejemplo se requiere que se haya agregado un RichTextBox control denominado richTextBox1, al formulario.

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

      // Specify a 20 pixel indent in all paragraphs.
      richTextBox1->SelectionIndent = 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 left edge of the RichTextBox.";
      richTextBox1->SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
      richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
      richTextBox1->SelectionIndent = 0;
      richTextBox1->SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
   }
private void WriteIndentedTextToRichTextBox()
{
    // Clear all text from the RichTextBox;
    richTextBox1.Clear();
    // Specify a 20 pixel indent in all paragraphs.
    richTextBox1.SelectionIndent = 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 left edge of the RichTextBox.";
    richTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter.";
    richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n\n";
    richTextBox1.SelectionIndent = 0;
    richTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge.";
}
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 indent in all paragraphs.
   RichTextBox1.SelectionIndent = 20
   ' Set the text within the control.
   RichTextBox1.SelectedText = "All text is indented 20 pixels from the left edge of the RichTextBox."
   RichTextBox1.SelectedText = "You can use this property to provide proper indentation such as when writing a letter."
   RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.Crlf
   RichTextBox1.SelectionIndent = 0
   RichTextBox1.SelectedText = "No indenation is applied to this paragraph. All text in the paragraph flows from each control edge."
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 SelectionRightIndent 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

Consulte también