RichTextBox.BulletIndent プロパティ

定義

箇条書きスタイルをテキストに適用する場合に、RichTextBox コントロール内で使用するインデント幅を取得または設定します。

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

プロパティ値

行頭文字の後にインデント幅として挿入するピクセルの数。 既定値は 0 です。

例外

指定したインデントが 0 未満でした。

次のコード例では、 プロパティを 、および SelectionColor プロパティと共BulletIndentSelectionFontSelectedTextに使用SelectionBulletして、コントロールに箇条書きを作成する方法をRichTextBox示します。 この例では、 という名前richTextBox1RichTextBoxコントロールをフォームに作成する必要があります。

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

注釈

箇条書きのスタイルをテキストの段落に適用するには、 プロパティを SelectionBullettrue 設定し、 プロパティに BulletIndent テキストをインデントするピクセル数を設定します。 段落には箇条書きのスタイルが適用され、行頭文字の後にインデントが指定されます。 このプロパティは、コントロールのテキスト内の現在の段落と、箇条書きの一覧で現在選択されている箇条書きにのみ影響します。 箇条書きアイテムのリスト全体に異なるインデント レベルを適用するには、 プロパティを設定する前に、箇条書きアイテムのすべてのテキストを BulletIndent 選択する必要があります。

適用対象

こちらもご覧ください