D
DJ Pomeroy
I just can't seem to get it...
I have a form. On this form is a panel. In this panel is a bunch of
objects - graphics, text, and so on. I want to be able to print what's in
the panel to a printer. I'm not using Crystal Reports. Here's the code I
have so far...
Basically, I don't know what to put in the "PrintPage" sub. Any ideas?
DJ Pomeroy
I have a form. On this form is a panel. In this panel is a bunch of
objects - graphics, text, and so on. I want to be able to print what's in
the panel to a printer. I'm not using Crystal Reports. Here's the code I
have so far...
Code:
Dim CurrPage As Integer
Dim LastPage As Integer
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrint.Click
With PrintDialog1
.AllowPrintToFile = False
.AllowSelection = True
.AllowSomePages = False
.PrinterSettings = New PrinterSettings
.PrinterSettings.PrintRange = PrintRange.Selection
If .ShowDialog <> DialogResult.OK Then Exit Sub
Dim LastPage As Integer = .PrinterSettings.Copies
Dim FirstPage As Integer = 1
PrintPages(FirstPage, LastPage)
End With
End Sub
Sub PrintPages(ByVal FirstPage As Integer, ByVal LastPage As Integer)
Me.CurrPage = FirstPage
Me.LastPage = LastPage
Me.PrintDocument2 = New PrintDocument
Try
PrintDocument2.Print()
Catch ex As Exception
MessageBox.Show(ex.Message, "Print error")
End Try
End Sub
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e
As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument2.PrintPage
Me.LastPage = LastPage
'What to print needs to be entered here.
CurrPage += 1
e.HasMorePages = (CurrPage <= LastPage)
End Sub
Basically, I don't know what to put in the "PrintPage" sub. Any ideas?
DJ Pomeroy