# Bullets and Numbered Lists

> Create bulleted, numbered and structured lists with ListFormat in Windows Forms, use the Bullets and Numbering dialog, restart numbering and define list styles.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Editor > Bullets and Numbered Lists
- **3360 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/lists/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/lists/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/lists/llms-full.txt

---

Bulleted lists, numbered lists and outlines with several levels, such as "1.", "1.1." and "1.1.1.", are paragraph formatting in TX Text Control. Users create them with the list buttons of the ribbon and the **Bullets and Numbering** dialog box; your code creates them with a `ListFormat` object, restarts numbering, builds list styles and reads the numbers the editor has assigned. Other paragraph attributes are described in [Text and Paragraph Formatting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/formatting/llms-full.txt).

### How Lists Work

A list is an attribute of paragraphs: each paragraph of a list has a [ListFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/llms-full.txt). Its [Type](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/type-property/llms-full.txt) is one of the [ListType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listtype/enumeration/llms-full.txt) values:

| Value | The paragraph is |
|---|---|
| `None` | Not part of a list |
| `Bulleted` | An item of a bulleted list |
| `Numbered` | An item of a numbered list |
| `Structured` | An item of a structured list, which shows the numbers of all higher levels in front of its own number, such as 2.1.3. |

Further facts to know before you write list code:

- **Levels.** [Level](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/level-property/llms-full.txt) is between 1 and 10, the value of [MaxLevel](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/maxlevel-field/llms-full.txt). The default is 1.
- **Numbering continues.** A numbered list continues the numbering of the list before it until [RestartNumbering](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/restartnumbering-property/llms-full.txt) starts a new one. [FirstNumber](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/firstnumber-property/llms-full.txt) sets the starting number, by default 1.
- **Indents.** [HangingIndent](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/hangingindent-property/llms-full.txt), by default 360 twips, and [LeftIndent](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/leftindent-property/llms-full.txt) position the bullet or number and the text.
- **Separator.** [FormatCharacter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/formatcharacter-property/llms-full.txt) decides what follows the bullet or number: `Tab`, the default, `Space` or `None`.
- **Mixed selections.** When the selection contains paragraphs with different list settings, the properties of `ListFormat` return their defaults. [IsCommonValueSelected](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/iscommonvalueselected-method/llms-full.txt) of the selection tells you whether a value is shared.

### Let Users Format Lists

The **Paragraph** group of the ribbon's formatting tab has buttons for bulleted, numbered and structured lists. [ListFormatDialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/listformatdialog-method/llms-full.txt) opens the **Bullets and Numbering** dialog box for the selected paragraphs, for example from a menu item of your own:

```csharp
private void bulletsAndNumberingMenuItem_Click(object sender, EventArgs e)
{
    textControl1.ListFormatDialog();
}
```

The dialog box offers the list types, the positions of the bullet or number and of the text, the separating character, the level, the bullet character and its size, and for numbered lists the number style, the start number, the text in front of and after the number, and whether to restart the numbering or continue the list:

![The Bullets and Numbering dialog box with the numbered list type selected, the formatting options, the bullet characters, the number format settings and the Restart numbering option marked.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/bullets-numbering-dialog.f8649bcb.webp)

`ListFormatDialog` returns `DialogResult.Cancel` if the user canceled or changed nothing, and `DialogResult.OK` otherwise.

### Create a Bulleted List

To turn the selected paragraphs into a list, create a `ListFormat`, set its attributes and assign it to [Selection.ListFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/listformat-property/llms-full.txt). The following `Click` handler in *Form1.cs* creates a bulleted list with a round bullet from the Arial font:

```csharp
private void bulletsButton_Click(object sender, EventArgs e)
{
    ListFormat bullets = new ListFormat(ListType.Bulleted);
    bullets.BulletCharacter = '•';
    bullets.FontName = "Arial";

    textControl1.Selection.ListFormat = bullets;
}
```

- **The bullet character.** By default, [BulletCharacter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/bulletcharacter-property/llms-full.txt) is the character B7 (hexadecimal) of the Windows Symbol font. Since version 23.0, it can be any Unicode character, and [FontName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/fontname-property/llms-full.txt) names the font it comes from. Without a font, the Symbol font is assumed.
- **Size.** [BulletSize](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/bulletsize-property/llms-full.txt) sets the size of the bullet; 0, the default, uses the font size of the list text.

### Create a Numbered List

A numbered list has a [NumberFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/numberformat/enumeration/llms-full.txt) and optional text around the number:

```csharp
private void numbersButton_Click(object sender, EventArgs e)
{
    ListFormat numbers = new ListFormat(ListType.Numbered);
    numbers.NumberFormat = NumberFormat.ArabicNumbers;
    numbers.TextAfterNumber = ".";
    numbers.FormatCharacter = ListFormatCharacter.Tab;

    textControl1.Selection.ListFormat = numbers;
}
```

- **Number formats.** [NumberFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/numberformat-property/llms-full.txt) is `ArabicNumbers` (1, 2, 3), `Letters` (a, b, c), `CapitalLetters` (A, B, C), `RomanNumbers` (I, II, III) or `SmallRomanNumbers` (i, ii, iii).
- **Text around the number.** [TextBeforeNumber](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/textbeforenumber-property/llms-full.txt) and [TextAfterNumber](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/textafternumber-property/llms-full.txt) hold up to 20 characters each, the value of [MaxText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/listformat/maxtext-field/llms-full.txt), such as "(" and ")" for "(1)". They replace the obsolete `CharBeforeNumber` and `CharAfterNumber`.

### Create a Multilevel List

A structured list shows the numbers of all higher levels, and the text before and after them, in front of each number. The level of a paragraph decides how deep it is nested:

```csharp
private void outlineButton_Click(object sender, EventArgs e)
{
    ListFormat outline = new ListFormat(ListType.Structured);
    outline.NumberFormat = NumberFormat.ArabicNumbers;
    outline.TextAfterNumber = ".";
    outline.Level = 2;

    textControl1.Selection.ListFormat = outline;
}
```

Paragraphs at level 2 of a structured list are numbered 1.1., 1.2. and so on, below the level 1 paragraph before them.

### Restart the Numbering

`RestartNumbering` set to `true` makes the selected paragraph the first item of a new list:

```csharp
private void restartButton_Click(object sender, EventArgs e)
{
    ListFormat restart = new ListFormat(ListType.Numbered);
    restart.RestartNumbering = true;
    restart.FirstNumber = 1;

    textControl1.Selection.ListFormat = restart;
}
```

As the blog article [Two Ways to Restart Numbered Lists in TX Text Control](https://www.textcontrol.com/blog/2021/11/03/two-ways-to-restart-numbered-lists/) explains, a new paragraph created with ENTER inherits `RestartNumbering`, so the next item would start again at 1. The article shows two remedies: code that resets the property for the new item, and list styles.

#### Use List Styles

With styles, users never touch `RestartNumbering` themselves. A "List" style continues the numbering, and a "List Restart" style restarts it and names "List" as the style of the following paragraph, so that the item after it continues the new list:

```csharp
private void AddListStyles()
{
    ParagraphStyle list = new ParagraphStyle("List");
    list.ListFormat = new ListFormat(ListType.Numbered) { RestartNumbering = false };
    list.FollowingStyle = "List";

    ParagraphStyle restart = new ParagraphStyle("List Restart", "List");
    restart.ListFormat = new ListFormat(ListType.Numbered) { RestartNumbering = true };
    restart.FollowingStyle = "List";

    textControl1.ParagraphStyles.Add(list);
    textControl1.ParagraphStyles.Add(restart);
}
```

Users can create the same styles in the styles dialog box: the **Numbering...** button sets the list attributes, and **Style for the following paragraph** names the style of the next paragraph:

![The New Style dialog box for a style named Restart, based on List, with List as the style for the following paragraph and the buttons Font, Paragraph, Tabs and Numbering.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/new-style-dialog.65b98466.webp)

[Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/stylesheets/llms-full.txt) explains styles in general.

### Remove a List

Assign a `ListFormat` of the type `None` to remove the list from the selected paragraphs:

```csharp
textControl1.Selection.ListFormat = new ListFormat(ListType.None);
```

### Read the List Numbers

The number that the editor displays in front of a paragraph isn't part of its text. [Paragraph.ListNumber](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/paragraph/listnumber-property/llms-full.txt) returns it, 0 for a paragraph outside a numbered list, and [ListNumberText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/paragraph/listnumbertext-property/llms-full.txt) returns it with the text before and after it. The following method lists the numbered paragraphs of the document; it needs `using System.Diagnostics;`:

```csharp
private void ShowNumbers()
{
    foreach (Paragraph paragraph in textControl1.Paragraphs)
    {
        if (paragraph.ListNumber > 0)
        {
            Debug.WriteLine(paragraph.ListNumberText + " " + paragraph.Text);
        }
    }
}
```

For a toolbar of your own, [InputFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/inputformat-property/llms-full.txt) reports the list at the input position through [BulletedList](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/bulletedlist-property/llms-full.txt), [NumberedList](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/numberedlist-property/llms-full.txt) and [StructuredList](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/inputformat/structuredlist-property/llms-full.txt).

### Next Steps

- [Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/stylesheets/llms-full.txt): list attributes in paragraph styles.
- [Text and Paragraph Formatting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/formatting/llms-full.txt): the other paragraph attributes.
- [Built-in Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/dialog-boxes/llms-full.txt): the other dialog boxes of the editor.

---

## Nearby

- **Previous:** [Stylesheets](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/stylesheets/llms-full.txt)
- **Next:** [Tables and Table Formulas](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/tables/llms-full.txt)
