Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Restarting numbered lists when concatenating documents

This source code snippet requires TX Text Control .NET
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 Download [15.99 KB, 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.

  1. private void ResetNumbering(int startIndex)
  2. {
  3. int ListEntryCounter = 0;
  4.  
  5. foreach (TXTextControl.Line curLine in textControl1.Lines)
  6. {
  7. if (curLine.Start < startIndex)
  8. continue;
  9.  
  10. textControl1.InputPosition = new TXTextControl.InputPosition(curLine.Start - 1);
  11.  
  12. if (textControl1.Selection.ListFormat.Type == TXTextControl.ListType.Numbered)
  13. {
  14. if (ListEntryCounter == 0)
  15. {
  16. textControl1.Selection.ListFormat.RestartNumbering = true;
  17. ListEntryCounter = 1;
  18. }
  19. else if (ListEntryCounter == 1)
  20. {
  21. textControl1.Selection.ListFormat.RestartNumbering = false;
  22. return;
  23. }
  24. }
  25. }
  26. }

The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio .NET 2005.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place