Hi,
i have a created a winform as design of print receipt . But now i want to print this tablelayoutpanel so that user can take a print . I have to user VB.net Visual studio 2005 .
i got this following link
http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/print-receipt-and-save-data-using-window-form-in-C-Sharp/
but its in c#.net , not able to convert by tool because its using some interop service and dllimport .
Please anyone suggest me the right way to do it .
My code which i got after conversion from C# to vb.net
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, _
e.Graphics.DrawImage(memoryImage, 0, 0);
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintScreen()
PrintPreviewDialog1.ShowDialog()
End Sub
<System.Runtime.InteropServices.DllImport("gdi32.dll")> _
Public static extern Long BitBlt(IntPtr hdcDest, Integer nXDest, Integer nYDest, Integer nWidth, Integer nHeight, IntPtr hdcSrc, Integer nXSrc, Integer nYSrc, Integer dwRop)
Private memoryImage As Bitmap
Private Sub PrintScreen()
Dim mygraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc()
Dim dc2 As IntPtr = memoryGraphics.GetHdc()
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub