Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

How to limit the pages in TX Text Control

This source code snippet requires TX Text Control .NET
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 Download [16.81 KB, 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.

  1. If TextControl1.Pages > pageLimit And TextControl1.Text.Length > 0 Then
  2. Dim lastLineLength As Integer
  3.  
  4. TextControl1.InputPosition = New TXTextControl.InputPosition(pageLimit + 1, 0, 0)
  5. lastLineLength = TextControl1.Lines.GetItem(TextControl1.InputPosition.TextPosition)_
  6. .Text.Length - 2
  7. TextControl1.Select(TextControl1.InputPosition.TextPosition + lastLineLength,_
  8. TextControl1.Text.Length - TextControl1.InputPosition.TextPosition)
  9. TextControl1.Selection.Text = ""
  10. End If

At least a TX Text Control .NET 11.0 trial version and Visual Basic .NET is required to open the sample project.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place