| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic .NET |
| Version: | 1.0 |
| Released: | June 29, 2005 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with Visual Basic .NET |
| Download code: | tx_sample_page_limit.zip |
Sometimes, it is required to limit the number of pages in a document. This very simple example shows how to realize that using the Changed event.
A global variable is used to store the expected total number of pages. This will be compared with the current number of pages in the Changed event. If the number of current pages is larger than the specified limitation, the complete text of the following pages is selected and deleted.
If TextControl1.Pages > pageLimit And TextControl1.Text.Length > 0 Then Dim lastLineLength As Integer TextControl1.InputPosition = New TXTextControl.InputPosition(pageLimit + 1, 0, 0) lastLineLength = TextControl1.Lines.GetItem(TextControl1.InputPosition.TextPosition)_ .Text.Length - 2 TextControl1.Select(TextControl1.InputPosition.TextPosition + lastLineLength,_ TextControl1.Text.Length - TextControl1.InputPosition.TextPosition) TextControl1.Selection.Text = "" End If
At least a TX Text Control .NET 11.0 trial version and Visual Basic .NET is required to open the sample project.