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

TX Text Control .NET with Component One's Print Preview

This source code snippet requires TX Text Control .NET
Author:TX Text Control Support Department
Language:Visual Basic .NET
Version:1.0
Released:July 29, 2005
Last modified:January 11, 2008
Requirements:TX Text Control .NET with Visual Basic .NET
Download code:tx_net_sample_preview.zip Download [12.67 KB, ZIP]
Click to enlarge

Using TX Text Control .NET with Component One's Print Preview

In this sample we would like to show you another .NET component that works well with the TX Text Control .NET. The ComponentOne Preview .NET component offers some advantages over the standard VS .NET print preview.

ComponentOne's control comes with the C1PrintPreview component and the C1PrintDocument component. In this sample, we are going to use the preview component only.

Using the components together is quite straight-forward: You need to create a custom PrintController, so that TX Text Control does not send its contents to the standard printer. The dummy PrintController does not do anything except return a Graphics object in the OnStartPage handler. As you cannot create a Graphics object without a Form or a Screen object, a reference to the parent form has to be set with the SetParent method.

  1. Private Class MyPrintController
  2. Inherits System.Drawing.Printing.PrintController
  3.  
  4. Private parent As Form1
  5.  
  6. Public Sub New()
  7. MyBase.New()
  8. End Sub
  9.  
  10. Public Sub SetParent(ByVal form As Form1)
  11. parent = form
  12. End Sub
  13.  
  14. Public Overloads Overrides Function OnStartPage(ByVal document_
  15. As System.Drawing.Printing.PrintDocument, ByVal e As System._
  16. Drawing.Printing.PrintPageEventArgs) As System.Drawing.Graphics
  17. OnStartPage = parent.CreateGraphics()
  18. End Function
  19.  
  20. Public Overloads Overrides Sub OnEndPage(ByVal document As_
  21. System.Drawing.Printing.PrintDocument, ByVal e As System.Drawing._
  22. Printing.PrintPageEventArgs)
  23. End Sub
  24.  
  25. Public Overloads Overrides Sub OnEndPrint(ByVal document As_
  26. System.Drawing.Printing.PrintDocument, ByVal e As System.Drawing._
  27. Printing.PrintEventArgs)
  28. End Sub
  29.  
  30. Public Overloads Overrides Sub OnStartPrint(ByVal document As_
  31. System.Drawing.Printing.PrintDocument, ByVal e As System.Drawing._
  32. Printing.PrintEventArgs)
  33. End Sub

The CreateGraphics method of this reference can be used in the OnStartPage event handler. Have a look at the code to see how it works.

Note that at least TX Text Control .NET 10.1 trial, a trial version of ComponentOne Preview .NET and Visual Studio VB .NET are required to run this sample.

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