RichTextBox.SelectionIndent Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit la longueur, en pixels, de la mise en retrait de la ligne où commence la sélection.
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
Valeur de propriété
Distance actuelle, en pixels, de la mise en retrait appliquée à gauche de la sélection de texte actuelle ou du point d’insertion.
- Attributs
Exemples
L’exemple de code suivant montre comment spécifier le texte mis en retrait dans la propriété à l’aide RichTextBox de la SelectionIndent propriété. Cet exemple nécessite qu’un RichTextBox contrôle nommé richTextBox1ait été ajouté au formulaire.
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
Remarques
Si aucun texte n’est actuellement sélectionné, le paramètre de retrait est appliqué au paragraphe dans lequel le point d’insertion apparaît et à tout le texte tapé dans le contrôle après le point d’insertion. Le paramètre de retrait s’applique jusqu’à ce que la propriété soit remplacée par une valeur différente ou jusqu’à ce que le point d’insertion soit déplacé vers un autre paragraphe dans le contrôle.
Si le texte est sélectionné dans le contrôle, le texte sélectionné et tout texte entré après la sélection de texte aura la valeur de cette propriété. Vous pouvez utiliser cette propriété pour mettre en retrait les paragraphes contenus dans le RichTextBoxdocument du . Vous pouvez utiliser cette propriété conjointement avec les SelectionRightIndent paragraphes pour créer des paragraphes affichés dans des paragraphes.
Pour créer un retrait négatif pour les paragraphes du contrôle, utilisez la SelectionHangingIndent propriété.