RichTextBox.BulletIndent Własność
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Pobiera lub ustawia wcięcie używane w kontrolce RichTextBox po zastosowaniu stylu punktora do tekstu.
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
Wartość nieruchomości
Liczba pikseli wstawionych jako wcięcie po punktorze. Wartością domyślną jest zero.
Wyjątki
Określone wcięcie było mniejsze niż zero.
Przykłady
W poniższym przykładzie kodu pokazano, jak używać SelectionBullet właściwości z właściwościami BulletIndent, SelectionFont, SelectedTexti SelectionColor w celu utworzenia listy punktowanej w kontrolce RichTextBox . Ten przykład wymaga utworzenia RichTextBox kontrolki o nazwie richTextBox1 na formularzu.
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
Uwagi
Aby zastosować styl punktora do akapitu tekstu, ustaw SelectionBullet właściwość na true , a następnie ustaw BulletIndent właściwość na liczbę pikseli, którą należy wcięć. Akapit będzie miał zastosowany styl punktora z określoną ilością wcięcia po punktorze. Ta właściwość ma wpływ tylko na bieżący akapit w tekście kontrolki i aktualnie zaznaczony punktor na liście punktowanych elementów. Aby zastosować inny poziom wcięcia do całej listy elementów punktowanych, przed ustawieniem BulletIndent właściwości należy wybrać cały tekst punktowanych elementów.