I have received several inquiries on how to programatically insert a page break using TX Text Control .NET for Windows Forms. Generally, this is quite simple: Just insert the control character for a page break using the Selection.Text property:
C#:
textControl1.Selection.Text = "\f";
VB .NET:
TextControl1.Selection.Text = Chr(12)
If you insert a page break using the key combination CTRL + ENTER, TX Text Control scrolls automatically to this new input position. TX Text Control won't scroll automatically, if you insert a page break by code as this might be not the intention of the developer.
To scroll to the new input position, the ScrollLocation property can be used:
C#:
private void InsertPageBreak()
{
textControl1.Selection.Text = "\f";
System.Drawing.Point ScrollPosition = new Point(0, textControl1.InputPosition.Location.Y);
textControl1.ScrollLocation = ScrollPosition;
textControl1.Focus();
}
VB .NET:
Private Sub InsertPageBreak()
TextControl1.Selection.Text = Chr(12)
Dim ScrollPosition As New System.Drawing.Point(0, TextControl1.InputPosition.Location.Y)
TextControl1.ScrollLocation = ScrollPosition
TextControl1.Focus()
End Sub
Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.
The TX Text Control logo is a registered trademark in the United States, Europe and other countries.