Print form to print preview with page setup

bones

Well-known member
Joined
Aug 23, 2014
Messages
143
Programming Experience
Beginner
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.PrintForm1.PrintAction = (Printing.PrintAction.PrintToPreview)
        Me.PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)


    End Sub

I want to print just the chart on a form and present the user with page setup option so they can switch to landscape printing and select whatever printer they desire.

No need to explain the code I started with...will be obvious to you guys....needed to start somewhere.

Have added Printform1, Pagesetupdialog, printpreviewdialog to form

Found some code for document printing but it doesn't mix with the powerpacks printform .... or so I can't get it to anyway. That code is below..

VB.NET:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim printdoc As New PrintDocument
        PageSetupDialog1.Document = printdoc
        PrintPreviewDialog1.Document = printdoc
        PageSetupDialog1.ShowDialog()
        PrintPreviewDialog1.ShowDialog()
        PrintPreviewControl1.Document = printdoc
    End Sub
 
Use the PrintDocument for printing instead. Printing just the chart is simple, create a Bitmap and draw chart to that with Chart.DrawToBitmap method, then draw the bitmap to page in PrintDocument.PrintPage event handler.
 
Use the PrintDocument for printing instead. Printing just the chart is simple, create a Bitmap and draw chart to that with Chart.DrawToBitmap method, then draw the bitmap to page in PrintDocument.PrintPage event handler.

Hmmm... did't know that was an option... Could that method be used to enlarge the printed chart to be larger than the screen displayed chart parameters?
 
Hmmm... did't know that was an option... Could that method be used to enlarge the printed chart to be larger than the screen displayed chart parameters?
If you mean stretch image drawn to PrintDocument page, then yes, Graphics.DrawImage method will do that if bitmap is different size than area you draw to.
 
Back
Top