I am having trouble figuring out how to print out a page with information that is changing to the printer.
Think of printing out packing slips. Each Packing Slip has a packing slip # and the contents of each packing slip are different.
For simplicity purposes I've pasted the basics of my code
In my Print Button Click Event I have
Dim print_Document As PrintDocument = PreparePackingSlipDocument()
Private Function PreparePackingSlipDocument() As PrintDocument
Dim print_document As New PrintDocument
AddHandler print_document.PrintPage, AddressOf Print_PackingSlip
Private Sub Print_PackingSlip(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim p As New Pen(Color.Black, 4)
Dim r As New Rectangle(200, 250, 300, 30)
e.Graphics.DrawString("HelloWorld", New Font("Verdana", 50, FontStyle.Bold), Brushes.Black, 150, 10)
I know in my Print_PackingSlip Sub is where all of my data will need to be setup so it can be displayed/printed to a page. But the problem I do not understand is how I can change all that information dynamically. Because each time I read from my database my Packing Slip information will be completely different so I need to change the text of what I want to print out.
I suppose I could just generate a bunch of variables and then use those variables in the Print_PackingSlip Sub but I was hoping not to do that because there may be a lot of information to print so I might end up wiht a lot of variables used only for printing
These subs are currently in my mainForm class. I guess I should moveall my printing information to its own separate class, but I could not find any sufficient material to help me move the code to a class so I just left it in the mainForm Class for now.