Moving to a Page, Line or Column

TX Text Control's InputPosition class informs you about which page, line and column the current input position is at. It can also be used to move the input position to a different location.

The following example shows how to create a Goto Page function. An instance of the InputPosition class is created and initialized with a previously entered page number. The new input position is then assigned to the TextControl.InputPosition property.

winGotoPage winGotoPage = new winGotoPage();

if (winGotoPage.PageNo > 0 && winGotoPage.PageNo <= textControl1.Pages)
    TXTextControl.InputPosition InputPosition =
        new TXTextControl.InputPosition(winGotoPage.PageNo, 1, 0);
    textControl1.InputPosition = InputPosition;
    MessageBox.Show("Page number outside valid range.");
[Visual Basic]
Dim winGotoPage As New winGotoPage()

If winGotoPage.PageNo > 0 AndAlso winGotoPage.PageNo <= textControl1.Pages Then
    Dim InputPosition As New TXTextControl.InputPosition(winGotoPage.PageNo, 1, 0)
    textControl1.InputPosition = InputPosition
    MessageBox.Show("Page number outside valid range.")
End If

Note that the InputPosition.Page property requires the ViewMode property to be set to PageView. In all other modes, text is displayed continuously as a single page, so the property will always have a value of 1.

<< Previous