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

屬性值

插入項目符號後面做為縮排的像素數目。 預設值是零。

例外狀況

指定的縮排小於零。

範例

下列程式碼範例示範如何使用 SelectionBullet 屬性搭配 BulletIndentSelectionFontSelectedTextSelectionColor 屬性,在 控制項中 RichTextBox 建立項目符號清單。 這個範例會要求 RichTextBox 在表單上建立名為 richTextBox1 的控制項。

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

備註

若要將專案符號樣式套用至文欄位落,請將 屬性 true 設定 SelectionBullet 為 ,然後將 屬性設定 BulletIndent 為應該縮排文字的圖元數。 段落會套用專案符號樣式,並在專案符號之後加上指定的縮排量。 此屬性只會影響控制項文字內的目前段落,以及專案符號專案中目前選取的專案符號。 若要將不同的縮排層級套用至整個專案符號專案清單,必須先選取專案符號專案的所有文字,才能設定 BulletIndent 屬性。

適用於

另請參閱