I'd like to eliminate storing the string in the TextBox2.Text and pass the parameter directly. How do I pass a parameter onto the Sub PrintDocument1_PrintPage? I'd like to do something like PrintDocument1.Print("test print")
********************
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TextBox2.Text = "test print"
PrintDialog1.Document = PrintDocument1 'PrintDialog associate with PrintDocument.
If PrintDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Create string to draw.
Dim drawString As [String] = TextBox2.Text
' Create font and brush.
Dim drawFont As New Font("Arial", 10)
Dim drawBrush As New SolidBrush(Color.Black)
' Create rectangle for drawing.
Dim x As Single = 50.0F
Dim y As Single = 50.0F
Dim width As Single = 200.0F
Dim height As Single = 50.0F
Dim drawRect As New RectangleF(x, y, width, height)
' Draw string to screen.
e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect)
End Sub
********************
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TextBox2.Text = "test print"
PrintDialog1.Document = PrintDocument1 'PrintDialog associate with PrintDocument.
If PrintDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Create string to draw.
Dim drawString As [String] = TextBox2.Text
' Create font and brush.
Dim drawFont As New Font("Arial", 10)
Dim drawBrush As New SolidBrush(Color.Black)
' Create rectangle for drawing.
Dim x As Single = 50.0F
Dim y As Single = 50.0F
Dim width As Single = 200.0F
Dim height As Single = 50.0F
Dim drawRect As New RectangleF(x, y, width, height)
' Draw string to screen.
e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect)
End Sub