In TX Text Control 14.0, we introduced formatting sections that allows you to split a document into separate sections to enable different page sizes, margins or headers and footers.

TX Text Control 15.0 additionally implements page columns that can be adjusted separately for each inserted section.

When you are not used to word processing, sections might not be self-explanatory. For instance, sections enables you to create documents with mixed page orientation, so that parts are inserted as portrait and other parts as landscape. It is possible to add different headers and footers to specific sections or you can include page numbering only for the main part of a document and omit it in an appendix.

Accessing the Sections

All sections are listed in the SectionCollection class that can be accessed using the Sections property.

By inserting a new section using the Add method, a section break character is inserted at the current input position. TX Text Control lets you insert a new section that starts at a new page or at a new line. The page size and different headers and footers can only be changed when inserting a new page.

All settings of the previous section are inherited when creating a new document section. In other words, if you inserted a specific header to the previous section, this header will be displayed in the new section as well. To avoid that, you can set the ConnectedToPrevious property of the HeaderFooter object to false. In this case, the new section is getting it's own header.

To modify the headers and footers of a specific section, you need to manipulate the HeadersAndFooters property of the specific section. In previous versions of TX Text Control, the headers and footers were accessed through the HeadersAndFooters property of the main control which is no longer recommended. It is still possible, but if you have more than 1 section, most of the other collections in the HeaderFooter object are NULL. Example:

You need to change the text of each header in every section. Therefore, you need to iterate through all sections and their headers and footers:

foreach (Section sec in textControl1.Sections)
    foreach (HeaderFooter hed in sec.HeadersAndFooters)
        hed.Selection.Text = "New Text";

Sections is a layer wrapped over the text and its pages. The text, images, tables and all other elements can be accessed using the normal collections of the main TX Text Control. Only the content in the different headers and footes must be accessed through the specific section.

The Section Dialog Box

TX Text Control is shipped with a dialog box that can be used to manipulate the section settings. The first screenshot shows the section format dialog that comes with TX Text Control. It allows you to change the page format for the complete document or the current section.

Text Control

The following screenshot shows the second tab of the same dialog box. On this tab page, it is possible to specify whether headers and footers are added to the current section, if they should be connected to the previous one and to adjust the different settings for headers and footers.

Text Control

In the combo boxes, you have three possibilities for headers and footers when applying the changes to the complete document:

  1. None: No header or footer is inserted
  2. All sections equal: All sections are getting the same header or footer
  3. All sections different: Each section is getting it's own header or footer

When applying the settings to the current section, you will have the following possibilities:

  1. None: No header or footer is inserted
  2. Same as previous section: The new header or footer is connected to the previous one
  3. This section different: The new header or footer is not connected to the previous one

With sections, TX Text Control provides you a powerful tool to create professional documents. Feel free to post questions you might have about sections.