I have looked on the web for a solution to print scrollable panel larger than can be fitted on the screen but couldn't find any solution and it looks like that many people has this problem!
PrintForm (printform powerpack component) can not do this because it only capture that part of the panel that is fitted on the screen.
And if you want to do this with the PrintDocument component and print all the visible parts of the form grids,tablelayoutpanels etc and to formate it correctly then you can become really frustrated!

Here is my solution to print scrollable panels larger than can be fitted on the screen..

    Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As Integer) As Integer

    Private Enum EDrawingOptions As Integer
        PRF_NONCLIENT = &H2
        PRF_CLIENT = &H4
        PRF_ERASEBKGND = &H8
        PRF_CHILDREN = &H10
        PRF_OWNED = &H20
    End Enum

    Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Const WM_PRINT As Integer = &H317
        Dim myBmp As Bitmap
        Dim myGraphics As Graphics
        Dim hdc As System.IntPtr

        Dim g As Graphics
        g = e.Graphics
        myBmp = New Bitmap(Panel1.DisplayRectangle.Width, Panel1.DisplayRectangle.Height)
        myGraphics = Graphics.FromImage(myBmp)
        hdc = myGraphics.GetHdc

        Call SendMessage(Panel1.Handle, WM_PRINT, hdc, EDrawingOptions.PRF_CHILDREN Or EDrawingOptions.PRF_CLIENT Or EDrawingOptions.PRF_NONCLIENT Or EDrawingOptions.PRF_OWNED)

        g.DrawImage(myBmp, 0, 0)
        e.HasMorePages = False
        myGraphics = Nothing
        myBmp = Nothing

    End Sub

    Private Sub SkrivUt1ExToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SkrivUt1ExToolStripMenuItem.Click


    End Sub

Hi Dragomir 1, welcome here at Daniweb.
You will never print a Panel. You will want to print what is drawn on the Panel,I guess.
I'm affraid you have to do some calculations example here and work with the HasMorePages property.

Thank you very much

That's work very well for me
Yeah !
I Replaced "Panel1". for "Me."

Edited 1 Week Ago by Jean-Philippe_1