次の方法で共有


RichTextBox.BulletIndent プロパティ

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

Public Property BulletIndent As Integer
[C#]
public int BulletIndent {get; set;}
[C++]
public: __property int get_BulletIndent();public: __property void set_BulletIndent(int);
[JScript]
public function get BulletIndent() : int;public function set BulletIndent(int);

プロパティ値

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

例外

例外の種類 条件
ArgumentException 指定したインデント幅が 0 未満でした。

解説

箇条書きスタイルをテキストの段落に適用するには、 SelectionBullet プロパティに true を設定してから、テキストに適用するインデント幅をピクセル数で BulletIndent プロパティに設定します。段落には、指定したインデント幅が行頭文字の後に挿入された箇条書きスタイルが適用されます。このプロパティは、コントロールのテキスト内の現在の段落、および箇条書き項目のリストで現在選択されている項目だけに適用されます。箇条書き項目のリスト全体に別のインデント幅を適用するには、 BulletIndent プロパティを設定する前に、箇条書き項目のテキストすべてを選択しておく必要があります。

使用例

[Visual Basic, C#, C++] BulletIndentSelectionFontSelectedTextSelectionColor の各プロパティと共に SelectionBullet プロパティを使用して、 RichTextBox コントロール内に箇条書きリストを作成する方法を次の例に示します。この例は、 richTextBox1 という名前の RichTextBox コントロールがフォーム上で作成されていることを前提にしています。

 
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

[C#] 
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";
}

[C++] 
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 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"  S"\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"  S"\n";
        richTextBox1->SelectionFont = new System::Drawing::Font(S"Arial", 12);
        richTextBox1->SelectionColor = Color::Purple;
        richTextBox1->SelectedText = S"Grapes"  S"\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"Verdana", 10);
        richTextBox1->SelectedText = S"The bulleted text is indented 30 pixels from the bullet symbol using the BulletIndent property.\n";
    }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

RichTextBox クラス | RichTextBox メンバ | System.Windows.Forms 名前空間 | SelectionBullet