TX Text Control .NET for Windows Forms

Add Method

Method
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Adds a new header or footer to a Text Control document or to a certain section of the document. If a header or footer is added to the complete document the first section receives the header or footer and all other sections receive headers or footers which are connected to their previous section. To add more than one header or footer a combination of the HeaderFooterType enumeration values can be used.

Syntax

public bool Add(HeaderFooterType headerFooterType);

Parameters

ParameterDescription
headerFooterType

Specifies the headers and/or footers to add. A combination of the following values of the HeaderFooterType enumeration is possible:

ValueMeaning
HeaderAdds a header to the document.
FirstPageHeaderAdds a special header to the document's first page.
FooterAdds a footer to the document.
FirstPageFooterAdds a special footer to the document's first page.
EvenHeaderAdds an even header to the document. Even and odd headers can only exist together. If a header already exists, the existing header becomes the odd header. Otherwise an odd header is also created.
EvenFooterAdds an even footer to the document. Even and odd footers can only exist together. If a footer already exists, the existing footer becomes the odd footer. Otherwise an odd footer is also created.
AllAdds all headers and footers.

Return Value

The return value is true, if the header or footer could be added. Otherwise it is false.

Examples

The following example adds a footer and inserts a centered confidentiality notice.

HeaderFooterCollection headersAndFooters = textControl.Sections[1].HeadersAndFooters;
if (headersAndFooters.Add(HeaderFooterType.Footer))
{
    HeaderFooter footer = headersAndFooters.GetItem(HeaderFooterType.Footer);
    footer.Selection.Text = "Confidential";
    footer.Selection.ParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Center;
}