Page 1 of 1
Custom printing preview
Posted: Mon Jan 30, 2006 9:18 am
by 8127944
I want do design my own printing preview dialog box. Normally i am using the PrintPreviewControl in combination with the PrintDocument component.
To show the chart preview, i tried to connect the PrintDocument property from the TeeChart - Printer class to my PrintPreviewControl.
In other circumstances i do PrintPreviewControl.InvalidatePreview() do update my preview. But it does not work für the tchart preview.
How can I trigger the PrintDocument from the the TeeChart - Printer class to redraw itselfe onto the connected PrintPreviewControl?
Thanks for your help, Markus
Posted: Tue Jan 31, 2006 9:40 am
by narcis
Hi Markus,
You should do somethink like that:
Code: Select all
Private storedPageSettings As PageSettings
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (storedPageSettings Is Nothing) Then
storedPageSettings = New PageSettings
storedPageSettings.Landscape = False
End If
TChart1.Printer.BeginPrint()
TChart1.Printer.Landscape = storedPageSettings.Landscape
TChart1.Printer.Print(New Rectangle(storedPageSettings.Bounds.Left + 50, storedPageSettings.Bounds.Top + (storedPageSettings.Bounds.Height / 2) + 50, storedPageSettings.Bounds.Width - 100, (storedPageSettings.Bounds.Height / 2) - 50))
Dim PDoc As System.Drawing.Printing.PrintDocument = TChart1.Printer.PrintDocument
Try
PDoc.DefaultPageSettings = storedPageSettings
Dim dlg As New PrintPreviewDialog
dlg.Document = PDoc
dlg.ShowDialog()
Catch ex As Exception
MessageBox.Show("An error occurred - " + ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim psDlg As New PageSetupDialog
Try
If (storedPageSettings Is Nothing) Then
storedPageSettings = New PageSettings
storedPageSettings.Landscape = True
End If
psDlg.PageSettings = storedPageSettings
psDlg.ShowDialog()
Catch ex As Exception
MessageBox.Show("An error occurred - " + ex.Message)
End Try
End Sub
Posted: Wed Feb 01, 2006 2:53 pm
by 8127944
Thanks for your help, no it works.
It is interesting that chaging the parameter "Resolution" of the printer class made everything easier. With setting this paramter to the value 10 i can handle the printer preview like all other previews - by simply setting the property "Document" of the .Net previe control to the property "printDocument" of the TeeChart Printer class.
Without changing the parameter "Resolution" ther was no output on the previe generated - no exception but also no output.
Anyway thanks for your quick hep, you doing a good job.
Greetings from Austria, Markus.