RichTextBox.SelectionBullet Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy styl punktora jest stosowany do bieżącego zaznaczenia lub punktu wstawiania.

public:
 property bool SelectionBullet { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool SelectionBullet { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionBullet : bool with get, set
Public Property SelectionBullet As Boolean

Wartość właściwości

Boolean

true jeśli bieżący punkt zaznaczenia lub punktu wstawiania ma zastosowany styl punktora; w przeciwnym razie , false.

Atrybuty

Przykłady

W poniższym przykładzie kodu pokazano, jak używać SelectionBullet właściwości z właściwościami SelectionFont, SelectedTexti SelectionColor w celu utworzenia listy punktowanej w kontrolce RichTextBox . Ten przykład wymaga utworzenia RichTextBox kontrolki o nazwie richTextBox1 w formularzu.

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 = 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( "Arial",16 );
      richTextBox1->SelectedText = "Bulleted Text Complete!";
   }
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!";
}
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

Uwagi

Jeśli żaden tekst nie jest zaznaczony, styl punktora jest stosowany do bieżącego punktu wstawiania i do wszystkich akapitów, które użytkownik wprowadza po punkcie wstawiania. Styl punktora jest stosowany do tekstu kontrolki do momentu przeniesienia punktu wstawiania lub naciśnięcia klawisza Enter na pustym elemencie punktora.

Jeśli tekst jest zaznaczony w kontrolce po ustawieniu tej właściwości, wszystkie akapity w zaznaczonym tekście są konwertowane na elementy punktowane na liście punktowanej. Za pomocą tej właściwości można tworzyć listy punktowane w dokumentach tworzonych w kontrolce RichTextBox .

Właściwość BulletIndent umożliwia określenie ilości wcięcia, które mają być stosowane między punktorem a tekstem elementu punktowanego.

Dotyczy

Zobacz też