In order to restart a list, you can simply set the restart numbering property for the list item to true. However, this can lead to confusion, because when return is pressed, this property is inherited to the next item and it restarts again. This can be overcome in different ways. The first strategy is to use FormattingStyles TX Text Control .NET for Windows Forms
TXTextControl Namespace
FormattingStyle Class
The FormattingStyle class is the base class for the InlineStyle and ParagraphStyle classes.
. The second approach is to process this in code behind.

Using Formatting Styles to Format Lists

Let's say you want to start a document with several lists. For this you will create a style using the styles dialog. Create a new style, name it List and select the preferred Numbering in the format category. Make sure to choose Continue list for this style. Anytime you want to start a list, you can simply apply this style.


Now consider, you wish to separate the list in the middle. Then you will need a second list style. Create an new style, name it Restart and select the preferred numbering. Since you want to restart the list, choose Restart numbering this time. Also, and this is important, choose List as style for the following paragraph. This makes sure that the list continues when adding new list items. The style Restart can now be used any time a list should be restarted.



Restart Lists Using the TX Text Control API

If you prefer to implement this as part of your application to take this out of the hands of the end user, this approach is for you. A sample project can be found at the end of this article. The approach is simple: A global flag is used that indicates if the next inserted list should be continued. When the list at the current input position should be restarted, the flag is changed to true. The KeyUp event is used to check if the Enter key is pressed. If yes, the RestartNumbering TX Text Control .NET for Windows Forms
TXTextControl Namespace
ListFormat Class
RestartNumbering Property
Gets or sets a value determining whether a new numbered list begins.
property is changed to false if inside a list so that the numbering continues for the newly inserted list items.

// global flag that indicates whether the next inserted list item
// should be continued
private bool restartFlag = false;
// restarts the numbering
private void button1_Click(object sender, EventArgs e)
textControl1.Selection.ListFormat.RestartNumbering = true;
restartFlag = true;
// continues the following paragraph (item), if the global flag is true
private void textControl1_KeyUp(object sender, KeyEventArgs e)
if (e.KeyCode != Keys.Return || restartFlag == false) return;
if (textControl1.Selection.ListFormat.Type == TXTextControl.ListType.Numbered)
textControl1.Selection.ListFormat.RestartNumbering = false;
restartFlag = false;
view raw test.cs hosted with ❤ by GitHub

Either way, restarting lists is very easy in Text Control and many ways lead to Rome. If you have further questions about these approaches, do not hesitate to contact us. Happy Coding!