| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual C# |
| Version: | 1.0 |
| Released: | September 25, 2007 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with C# |
| Download code: | tx_lists_restart.zip |
TX Text Control continues numbered lists automatically, if documents are inserted into an existing document. This makes sense in cases in which documents are created from multiple text snippets.
There are some scenarios, however, in which the numbering of a list should be maintained.
For this purpose, TX Text Control's API offers a method to restart a list at a specific position. The Lines collection can be used to iterate through the newly inserted lines. Before a new document is inserted, the last character index position is stored in order to get only the lists of the new document.
If the first list item is found, the list is restarted using the ListFormat.RestartNumbering method. On the second item, the list must be continued explicitly.
private void ResetNumbering(int startIndex) { int ListEntryCounter = 0; foreach (TXTextControl.Line curLine in textControl1.Lines) { if (curLine.Start < startIndex) continue; textControl1.InputPosition = new TXTextControl.InputPosition(curLine.Start - 1); if (textControl1.Selection.ListFormat.Type == TXTextControl.ListType.Numbered) { if (ListEntryCounter == 0) { textControl1.Selection.ListFormat.RestartNumbering = true; ListEntryCounter = 1; } else if (ListEntryCounter == 1) { textControl1.Selection.ListFormat.RestartNumbering = false; return; } } } }
The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio .NET 2005.