RichTextBox.BulletIndent Propriété

Définition

Obtient ou définit la mise en retrait utilisée dans le contrôle RichTextBox lorsque le style de liste à puces est appliqué au texte.

public:
 property int BulletIndent { int get(); void set(int value); };
public int BulletIndent { get; set; }
member this.BulletIndent : int with get, set
Public Property BulletIndent As Integer

Valeur de propriété

Int32

Nombre de pixels insérés comme mise en retrait après une puce. La valeur par défaut est zéro.

Exceptions

La mise en retrait spécifiée est inférieure à zéro.

Exemples

L’exemple de code suivant montre comment utiliser la propriété avec les SelectionBullet BulletIndentpropriétés , et SelectionColor SelectionFontSelectedTextles propriétés pour créer une liste à puces dans un RichTextBox contrôle. Cet exemple nécessite qu’un RichTextBox contrôle nommé richTextBox1 soit créé sur un formulaire.

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

      // Indent bulleted text 30 pixels away from the bullet.
      richTextBox1->BulletIndent = 30;

      // Set the font for the opening text to a larger Arial font;
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",16 );

      // Assign the introduction text to the RichTextBox control.
      richTextBox1->SelectedText = "The following is a list of bulleted items:\n";

      // Set the Font for the first item to a smaller size Arial font.
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );

      // Specify that the following items are to be added to a bulleted list.
      richTextBox1->SelectionBullet = true;

      // Set the color of the item text.
      richTextBox1->SelectionColor = Color::Red;

      // Assign the text to the bulleted item.
      richTextBox1->SelectedText = "Apples"
      "\n";

      // Apply same font since font settings do not carry to next line.
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );
      richTextBox1->SelectionColor = Color::Orange;
      richTextBox1->SelectedText = "Oranges"
      "\n";
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );
      richTextBox1->SelectionColor = Color::Purple;
      richTextBox1->SelectedText = "Grapes"
      "\n";

      // End the bulleted list.
      richTextBox1->SelectionBullet = false;

      // Specify the font size and string for text displayed below bulleted list.
      richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Verdana",10 );
      richTextBox1->SelectedText = "The bulleted text is indented 30 pixels from the bullet symbol using the BulletIndent property.\n";
   }
private void WriteTextToRichTextBox()
{
   // Clear all text from the RichTextBox;
   richTextBox1.Clear();
   // Indent bulleted text 30 pixels away from the bullet.
   richTextBox1.BulletIndent = 30;
   // Set the font for the opening text to a larger Arial font;
   richTextBox1.SelectionFont = new Font("Arial", 16);
   // Assign the introduction text to the RichTextBox control.
   richTextBox1.SelectedText = "The following is a list of bulleted items:\n";
   // Set the Font for the first item to a smaller size Arial font.
   richTextBox1.SelectionFont = new Font("Arial", 12);
   // Specify that the following items are to be added to a bulleted list.
   richTextBox1.SelectionBullet = true;
   // Set the color of the item text.
   richTextBox1.SelectionColor = Color.Red;
   // Assign the text to the bulleted item.
   richTextBox1.SelectedText = "Apples" + "\n";
   // Apply same font since font settings do not carry to next line.
   richTextBox1.SelectionFont = new Font("Arial", 12);
   richTextBox1.SelectionColor = Color.Orange;
   richTextBox1.SelectedText = "Oranges" + "\n";
   richTextBox1.SelectionFont = new Font("Arial", 12);
   richTextBox1.SelectionColor = Color.Purple;
   richTextBox1.SelectedText = "Grapes" + "\n";
   // End the bulleted list.
   richTextBox1.SelectionBullet = false;
   // Specify the font size and string for text displayed below bulleted list.
   richTextBox1.SelectionFont = new Font("Verdana", 10);
   richTextBox1.SelectedText = "The bulleted text is indented 30 pixels from the bullet symbol using the BulletIndent property.\n";
}
Private Sub WriteTextToRichTextBox()
   ' Clear all text from the RichTextBox;
   richTextBox1.Clear()
   ' Indent bulleted text 30 pixels away from the bullet.
   richTextBox1.BulletIndent = 30
   ' Set the font for the opening text to a larger Arial font;
   richTextBox1.SelectionFont = New Font("Arial", 16)
   ' Assign the introduction text to the RichTextBox control.
   RichTextBox1.SelectedText = "The following is a list of bulleted items:" + ControlChars.Cr
   ' Set the Font for the first item to a smaller size Arial font.
   richTextBox1.SelectionFont = New Font("Arial", 12)
   ' Specify that the following items are to be added to a bulleted list.
   richTextBox1.SelectionBullet = True
   ' Set the color of the item text.
   richTextBox1.SelectionColor = Color.Red
   ' Assign the text to the bulleted item.
   richTextBox1.SelectedText = "Apples" + ControlChars.Cr
   ' Apply same font since font settings do not carry to next line.
   richTextBox1.SelectionFont = New Font("Arial", 12)
   richTextBox1.SelectionColor = Color.Orange
   richTextBox1.SelectedText = "Oranges" + ControlChars.Cr
   richTextBox1.SelectionFont = New Font("Arial", 12)
   richTextBox1.SelectionColor = Color.Purple
   richTextBox1.SelectedText = "Grapes" + ControlChars.Cr
   ' End the bulleted list.
   richTextBox1.SelectionBullet = False
   ' Specify the font size and string for text displayed below bulleted list.
   richTextBox1.SelectionFont = New Font("Verdana", 10)
   richTextBox1.SelectedText = "The bulleted text is indented 30 pixels from the bullet symbol using the BulletIndent property." + ControlChars.Cr
End Sub

Remarques

Pour appliquer le style de puce à un paragraphe de texte, définissez la SelectionBullet propriété sur, puis définissez la BulletIndent propriété true sur le nombre de pixels à mettre en retrait. Le paragraphe aura le style de puce appliqué à celui-ci avec la quantité spécifiée de retrait après la puce. Cette propriété affecte uniquement le paragraphe actuel dans le texte du contrôle et la puce actuellement sélectionnée dans une liste d’éléments à puces. Pour appliquer un niveau de retrait différent à une liste entière d’éléments à puces, tout le texte des éléments à puces doit être sélectionné avant de définir la BulletIndent propriété.

S’applique à

Voir aussi