Compartilhar via


RichTextBox.SelectionIndent Propriedade

Definição

Obtém ou define o comprimento, em pixels, do recuo da linha em que a seleção é iniciada.

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 da propriedade

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

Atributos

Exemplos

O exemplo de código a seguir demonstra como especificar o texto recuado dentro da RichTextBox propriedade usando a SelectionIndent propriedade. Este exemplo requer que um RichTextBox controle, nomeado 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

Comentários

Se nenhum texto estiver selecionado no momento, a configuração de recuo será aplicada ao parágrafo no qual o ponto de inserção é exibido e a todo o texto digitado no controle após o ponto de inserção. A configuração de recuo se aplica 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 controle.

Se o texto for selecionado dentro do controle, o texto selecionado e qualquer texto inserido após a seleção de texto terão o valor dessa propriedade aplicado a ele. Você pode usar essa propriedade para recuar parágrafos contidos no documento do RichTextBox. Você pode usar essa propriedade em conjunto com os SelectionRightIndent parágrafos para criar exibidos em parágrafos.

Para criar um recuo deslocado para parágrafos no controle, use a SelectionHangingIndent propriedade.

Aplica-se a

Confira também