RichTextBox.SelectionHangingIndent 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 distance entre le bord gauche du premier trait de texte du paragraphe sélectionné et le bord gauche des lignes suivantes du même paragraphe.
public:
property int SelectionHangingIndent { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionHangingIndent { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionHangingIndent : int with get, set
Public Property SelectionHangingIndent As Integer
Valeur de propriété
Distance, en pixels, du retrait suspendu appliqué à la sélection de texte actuelle ou au point d’insertion.
- Attributs
Exemples
L’exemple de code suivant montre comment spécifier des retraits suspendus dans l’utilisation RichTextBox de la SelectionHangingIndent 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 hanging indent in all paragraphs.
richTextBox1->SelectionHangingIndent = 20;
// Set the font for the text.
richTextBox1->Font = gcnew System::Drawing::Font( "Lucinda Console",12 );
// Set the text within the control.
richTextBox1->SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
richTextBox1->SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
richTextBox1->SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
richTextBox1->SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
}
private void WriteIndentedTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1.Clear();
// Specify a 20 pixel hanging indent in all paragraphs.
richTextBox1.SelectionHangingIndent = 20;
// Set the font for the text.
richTextBox1.Font = new Font("Lucinda Console", 12);
// Set the text within the control.
richTextBox1.SelectedText = "This text contains a hanging indent. The first sentence of the paragraph is spaced normally.";
richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
richTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing.\n";
richTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph.";
richTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent.";
}
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 hanging indent in all paragraphs.
RichTextBox1.SelectionHangingIndent = 20
' Set the text within the control.
RichTextBox1.SelectedText = "VBThis text contains a hanging indent. The first sentence of the paragraph is spaced normally."
RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
RichTextBox1.SelectedText = "After this paragraph the indent is returned to normal spacing." + ControlChars.CrLf
RichTextBox1.SelectedText = "Since this is a new paragraph the indent is also applied to this paragraph."
RichTextBox1.SelectedText = "All subsequent lines of text are indented based on the value of SelectionHangingIndent."
End Sub
Remarques
Si aucun texte n’est actuellement sélectionné, le retrait suspendu 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 suspendu 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 appliquer un retrait négatif à vos paragraphes.
Pour définir la mise en retrait de la première ligne d’une sélection de paragraphes, utilisez la SelectionIndent propriété.