PageNumberFieldCollection Class
- Namespace
TXTextControl
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WinForms. SDK
- Assembly
TXTextControl.dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WinForms. SDK TXTextControl.from the setup.dll
- Inherits
- Text
Field Collection Base - Page
Number Field Collection
- Text
- Implements
- ICollection, IEnumerable
Description
An instance of the PageNumberFieldCollection class contains the page number fields in a header or footer of a Text Control document. Page number fields are represented through objects of the type PageNumberField. An instance of this class can be obtained with the HeaderFooter.PageNumberFields property. The PageNumberFieldCollection class implements the IEnumerable and the ICollection interfaces. For more information see the technical article Text Fields and Hypertext Links.
Syntax
public sealed class PageNumberFieldCollection : TextFieldCollectionBasePublic NotInheritable Class PageNumberFieldCollection
Inherits TextFieldCollectionBaseExamples
The following example obtains a footer's page-number collection and builds a “Page X of Y” label.
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer);
HeaderFooter footer = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer);
PageNumberFieldCollection fields = footer.PageNumberFields;
footer.Selection.Text = "Page ";
fields.Add(new PageNumberField());
footer.Selection.Text = " of ";
fields.Add(new PageNumberField() { ShowNumberOfPages = true });textControl.HeadersAndFooters.Add(HeaderFooterType.Footer)
Dim footer As HeaderFooter = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer)
Dim fields As PageNumberFieldCollection = footer.PageNumberFields
footer.Selection.Text = "Page "
fields.Add(New PageNumberField())
footer.Selection.Text = " of "
fields.Add(New PageNumberField() With { .ShowNumberOfPages = True })Members
Properties
| Property | Description |
|---|---|
| CanAdd | Gets a value indicating whether a new text field can be inserted at the current input position. It is true if a text field can be inserted, otherwise it is false. Text Control cannot insert a text field inside of another text field. (Inherited from TextFieldCollectionBase.) |
| Count | Gets the number of elements contained in the collection. (Inherited from TextFieldCollectionBase.) |
| IsSynchronized | Returns true if the collection is designed to be thread safe, otherwise, it returns false. (Inherited from TextFieldCollectionBase.) |
| Item | Gets the field with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the PageNumberFieldCollection class. |
| SyncRoot | Gets an object that can be used to synchronize access to the collection. (Inherited from TextFieldCollectionBase.) |
Methods
| Method | Description |
|---|---|
| Add | Inserts a new page number field at the current input position of a header or footer. |
| Clear | Removes all page number fields contained in the collection from the document. |
| CopyTo | Copies the elements of the collection to an array, starting at a particular index. |
| GetEnumerator | Returns an enumerator that can be used to iterate through the collection. (Inherited from TextFieldCollectionBase.) |
| GetItem | Gets a particular page number field from the collection. |
| Remove | Removes a page number from a header or footer of a Text control document. |