Custom printing preview

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Markus
Newbie
Newbie
Posts: 23
Joined: Tue Nov 23, 2004 5:00 am
Location: Austria
Contact:

Custom printing preview

Post by Markus » Mon Jan 30, 2006 9:18 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 31, 2006 9:40 am

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
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Markus
Newbie
Newbie
Posts: 23
Joined: Tue Nov 23, 2004 5:00 am
Location: Austria
Contact:

Post by Markus » Wed Feb 01, 2006 2:53 pm

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.

Post Reply