RichTextBox.SelectionIndent Propriedade

Definição

Obtém ou define o comprimento, em píxeis, da indentação da linha onde a seleção começa.

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 Propriedade

A distância atual, em pixels, da indentação aplicada à esquerda da seleção de texto atual ou do ponto de inserção.

Atributos

Exemplos

O exemplo de código seguinte demonstra como especificar texto em recuo dentro da RichTextBox propriedade usando a SelectionIndent propriedade. Este exemplo exige que um RichTextBox controlo, chamado richTextBox1, tenha sido adicionado ao formulário.

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

Observações

Se não houver texto selecionado, a definição de indentação é aplicada ao parágrafo onde aparece o ponto de inserção e a todo o texto que é digitado no controlo após o ponto de inserção. A definição de indentação aplica-se até que a propriedade seja alterada para um valor diferente ou até que o ponto de inserção seja movido para um parágrafo diferente dentro do controlo.

Se o texto for selecionado dentro do controlo, o texto selecionado e qualquer texto inserido após a seleção do texto terão o valor desta propriedade aplicado. Pode usar esta propriedade para indentar parágrafos contidos no documento do RichTextBox. Pode usar esta propriedade em conjunto SelectionRightIndent com para criar parágrafos apresentados em parágrafos.

Para criar uma reentrância pendente para parágrafos no controlo, use a SelectionHangingIndent propriedade.

Aplica-se a

Ver também