How can I print what I have drawn on a component..

  • Thread starter Thread starter William Cruz
  • Start date Start date
W

William Cruz

I am using a "panel" component as a canvas to draw some graphics. How
can I print what’s on the panel component. Thanks in advance for your
help.

William Cruz
 
William Cruz said:
I am using a "panel" component as a canvas to draw some graphics. How
can I print what's on the panel component.

\\\
Private Sub Panel1_Paint( _
ByVal sender As Object, _
ByVal e As PaintEventArgs _
) Handles Panel1.Paint
e.Graphics.DrawLine( _
Pens.Red, _
0, 0, _
Me.Panel1.ClientSize.Width, Me.Panel1.ClientSize.Height _
)
e.Graphics.DrawLine( _
Pens.Red, _
0, Me.Panel1.ClientSize.Height, _
Me.Panel1.ClientSize.Width, 0 _
)
End Sub

Private WithEvents m_PrintDocument As PrintDocument

Private Sub ButtonPrint_Click(...) Handles Button1.Click
m_PrintDocument = New PrintDocument
m_PrintDocument.Print()
End Sub

Private Sub m_PrintDocument_PrintPage( _
ByVal sender As Object, _
ByVal e As PrintPageEventArgs _
) Handles m_PrintDocument.PrintPage
Dim mi As MethodInfo = _
Me.Panel1.GetType().GetMethod( _
"OnPaint", _
BindingFlags.Instance Or BindingFlags.NonPublic _
)
mi.Invoke( _
Me.Panel1, _
New Object() { _
New PaintEventArgs(e.Graphics, New Rectangle(0, 0, 0, 0)) _
} _
)
End Sub
///
 
This works awesome, thanks. Now one more question. Currently the image
prints @ the top left corner of the page. How can I gain control of
location of the print out. Another thing, on the image, I have some
text_box’s that I also want to print but only the image prints & not the
text_box. Thanks.

William Cruz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top