A Deeper Look at TX Text Control .NET for Windows Forms's Page Class
The Page class has been part of TX Text Control's API since version 14.0. In case you either didn't use it or you were not aware of such a class, this post should give you an overview of it and it's benefits. The Page object represents a formatted page of the current document. Even though a document in TX Text Control is represented by floating text, the Page object is a view of a specific page in the current state. Prior the introduction of this class, it was quite tricky to select a…

The Page class has been part of TX Text Control's API since version 14.0. In case you either didn't use it or you were not aware of such a class, this post should give you an overview of it and it's benefits.
The Page object represents a formatted page of the current document. Even though a document in TX Text Control is represented by floating text, the Page object is a view of a specific page in the current state.
Prior the introduction of this class, it was quite tricky to select a complete page, to scroll to a specific page or to get the bounding rectangle associated with a page.
The members of the Page class are listed in the following diagram:
Property | Description |
Bounds | Gets the bounding rectangle of the page, in twips, relative to the top of the document. |
Length | Gets the number of characters of the page, including the page break character at the end of the page. |
Number | Gets the page's number. |
NumberInSection | Gets the page number relative to the beginning of the section the page belongs to. |
Section | Gets the number, one-based, of the section the page belongs to. |
Start | Gets the number (one-based) of the page's first character. |
TextBounds | Gets the bounding rectangle of the page's text, in twips, relative to the top of the document. |
Method | Description |
GetImage | Gets an image of the page's contents. |
Select | Selects the text of the page. |
To get a specific page of the collection, you can use the indexer of the PageCollection. The following code returns the start position (character index) of the second page:
// [C#]
int iStartValue = textControl1.GetPages()[2].Start;
Now, how to use this class to scroll to a specific page? The Bounds property of the Page class returns a bounding rectangle of the page relative to the top of the document. This value can be used with the ScrollLocation property. The following code can be used to scroll to the top of page 2:
// [C#]
textControl1.ScrollLocation = new Point(textControl1.ScrollLocation.X,
textControl1.GetPages()[2].Bounds.Top);
Additionally, the GetImage method can be used to create a bitmap or metafile representation of the current page:
// [C#]
Bitmap bmpPage = textControl1.GetPages()[2].GetImage(100,
TXTextControl.Page.PageContent.All);
An important notice at the end: The PageCollection is only available, if the TextControl.ViewMode property has been set to PageView.
Related Posts
Building Dashboard Reports with TX Text Control
We prepared many different demos and sample templates for various conferences in the last weeks. At DevConnections, we presented the latest features of TX Text Control X8 including the new…
TX Text Control, Windows 8 and Visual Studio 11: It Simply Works!
At the BUILD conference back in September 2011, Microsoft revealed the roadmap for Windows 8. Since then, developers and users were confused about what's possible and what's supported in the next…
TX Text Control's Smart Selection Interface
TX Text Control implements some special mouse and keyboard assignments to assist with typical selection tasks. The following tables contain these specific assignments: Mouse Assignments and Smart…
Spell CheckingTechnical Article
Deploying TX Spell .NET in an XBAP Browser Application
XBAP is a very smart way to deploy full .NET Framework WPF applications in the browser. With .NET 3.5 and 4.0, that means MS Internet Explorer and Firefox. Of course, TX Spell .NET for WPF and the…
Spell CheckingTechnical Article
TX Spell: Performance Considerations
TX Spell .NET has been built from ground up to match the key principles of performance, reliability and accuracy. Based on our experience in word processing applications, we were able to develop a…