Moving to a Page, Line or Column

Windows Forms User's Guide > Howto: Edit and Format Text From Code

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.

frmGotoPage GotoPage = new frmGotoPage();
if (GotoPage.PageNo > 0 && GotoPage.PageNo <= textControl1.Pages)
    TXTextControl.InputPosition InputPosition = 
        new TXTextControl.InputPosition(GotoPage.PageNo,1,0);
    textControl1.InputPosition = InputPosition;
    MessageBox.Show("Page number outside valid range.");
[Visual Basic]
PageNo = InputBox("Page no.", "Go to page", "1")PageNo = I
If PageNo > 0 And PageNo <= TextControl1.Pages Then
    Dim InputPosition As New TXTextControl.InputPosition(PageNo, 1, 0)
    TextControl1.InputPosition = InputPosition
    MsgBox("Page number outside valid range.", MsgBoxStyle.Exclamation)
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.