With version 14.0, we introduced document section breaks that allow you to have different page formats in the same document. Version 15.0 implements page columns that can be adjusted section-wise.

Sometimes, it is required to remove all section breaks from a document. This little code snippet shows you how to realize this using the enumerator of the section collection:

private void RemoveAllSections()
{
    TXTextControl.SectionCollection.SectionEnumerator sectionEnum = textControl1.Sections.GetEnumerator();
    int sectionCounter = textControl1.Sections.Count;

    sectionEnum.Reset();
    sectionEnum.MoveNext();
    for (int i = 0; i < sectionCounter; i++)
    {
        TXTextControl.Section curSection = (TXTextControl.Section)sectionEnum.Current;

        if (curSection.Number == 1)
        {
            sectionEnum.MoveNext();
            continue;
        }

        textControl1.Selection.Start = curSection.Start - 2;
        textControl1.Selection.Length = 1;
        textControl1.Selection.Text = "";
    }
 }

As you can see in the loop, it is not required to move to the next current item using the MoveNext() method as we are removing sections dynamically in the same loop.

Feel free to share your comments. I am currently preparing a blog series about the amazing new features of TX Text Control. I will start soon with the ASP.NET DocumentViewer.