Export (0) Print
Expand All

RichTextBox.SelectionBullet Property

Gets or sets a value indicating whether the bullet style is applied to the current selection or insertion point.

[Visual Basic]
Public Property SelectionBullet As Boolean
[C#]
public bool SelectionBullet {get; set;}
[C++]
public: __property bool get_SelectionBullet();
public: __property void set_SelectionBullet(bool);
[JScript]
public function get SelectionBullet() : Boolean;
public function set SelectionBullet(Boolean);

Property Value

true if the current selection or insertion point has the bullet style applied; otherwise, false.

Remarks

If no text is selected, the bullet style is applied to the current insertion point and to all paragraphs that the user enters after the insertion point. The bullet style is applied to the text of the control until the insertion point is moved or when the user presses the Enter key on an empty bullet item.

If text is selected within the control when this property is set, all paragraphs within the selected text are converted into bulleted items in the bulleted list. You can use this property to create bulleted lists within the documents you create in the RichTextBox control.

The BulletIndent property enables you to specify the amount of indentation to apply between the bullet and the bulleted item's text.

Example

[Visual Basic, C#, C++] The following example demonstrates how to use the SelectionBullet property with the SelectionFont, SelectedText, and SelectionColor properties to create a bulleted list in a RichTextBox control. This example assumes that a RichTextBox control named richTextBox1 is created on a form.

[Visual Basic] 
Private Sub WriteTextToRichTextBox()
   ' Clear all text from the RichTextBox;
   richTextBox1.Clear()
   ' 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("Arial", 16)
   richTextBox1.SelectedText = "Bulleted Text Complete!"
End Sub

[C#] 
private void WriteTextToRichTextBox()
{
   // Clear all text from the RichTextBox;
   richTextBox1.Clear();
   // 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("Arial", 16);
   richTextBox1.SelectedText = "Bulleted Text Complete!";
}

[C++] 
private:
    void WriteTextToRichTextBox() {
        // Clear all text from the RichTextBox;
        richTextBox1->Clear();
        // Set the font for the opening text to a larger Arial font;
        richTextBox1->SelectionFont = new System::Drawing::Font(S"Arial", 16);
        // Assign the introduction text to the RichTextBox control.
        richTextBox1->SelectedText = S"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 System::Drawing::Font(S"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 = S"Apples \n";
        // Apply same font since font settings do not carry to next line.
        richTextBox1->SelectionFont = new System::Drawing::Font(S"Arial", 12);
        richTextBox1->SelectionColor = Color::Orange;
        richTextBox1->SelectedText = S"Oranges \n";
        richTextBox1->SelectionFont = new System::Drawing::Font(S"Arial", 12);
        richTextBox1->SelectionColor = Color::Purple;
        richTextBox1->SelectedText = S"Grapes \n";
        // End the bulleted list.
        richTextBox1->SelectionBullet = false;
        // Specify the font size and string for text displayed below bulleted list.
        richTextBox1->SelectionFont = new System::Drawing::Font(S"Arial", 16);
        richTextBox1->SelectedText = S"Bulleted Text Complete!";
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RichTextBox Class | RichTextBox Members | System.Windows.Forms Namespace | BulletIndent

Show:
© 2015 Microsoft