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

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 2.0 |
| Released: | March 11, 2008 |
| Last modified: | March 11, 2008 |
| Requirements: | TX Text Control .NET with Visual Studio 2005 |
| Download code: | tx_printpreview_sample.zip |

TX Text Control implements the standard print preview dialog of the .NET Framework. Using the PrintPreview method, a PrintDocument can be passed to open this dialog. However, it is not possible to manipulate the dialog using this approach. Sometimes, it is necessary to maximize the form on showing the dialog.
Using TX Text Control's Print method, it is possible to print into a PrintDocument. This PrintDocument can be passed to a standard print preview dialog.
private void button1_Click(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); PrintPreview(pd); }
In TX Text Control 14, sections have been introduced as a new feature, so a single document may hold different page formats and orientations. The OnPrintPage and OnQueryPageSettings events are used in this case to handle the number of pages to be printed and the current page's settings.
private void OnPrintPage(object obj, PrintPageEventArgs ppe) { // print the contents of TX Text Control textControl1.Print(m_currentPage, ppe); if (m_currentPage == textControl1.Pages) ppe.HasMorePages = false; else { ppe.HasMorePages = true; m_currentPage++; } } private void OnQueryPageSettings(object obj, QueryPageSettingsEventArgs qpe) { // retrieve the page orientation of the currently printed page textControl1.InputPosition = new TXTextControl.InputPosition(m_currentPage, 1, 0); qpe.PageSettings.Landscape = textControl1.Sections.GetItem().Format.Landscape; }
A good sample for the use of sections is to append several documents and to print the result. This can be easily tested with this sample, just perform the following steps:
Note that at least TX Text Control .NET 14.0 trial version and Visual Studio .NET 2005 are required to run this sample.