Question Help with Printform / Autosize

jbrookley

Member
Joined
Jan 8, 2009
Messages
11
Programming Experience
1-3
Hello everyone!

I'm having trouble using printform to print my main form. My problem is that the form itself is too large to fit on an 8x11 page so it's only printing the top right corner. What I'm trying to do is put the form in landscape mode and either autosize the form or print the section I need printed.

A few specs:

My screen resolution is 1600 x 1200
My main form is 1222 x 956
VoltageGrid (a gridview item) is 443 x 597
CurrentGrid (another gridview item) is 743 x 421
Area I want / need printed:
Location: 12, 313
Size: 1190 x 597
(So basically, I need the bottom portion of the form printed off)

Here is my current code:

VB.NET:
      'Backs up form and grid background colors and changes them for printing
        Dim clrOld1 As New Color
        Dim clrOld2 As New Color
        Dim clrOld3 As New Color
        clrOld1 = Me.BackColor
        clrOld2 = VoltageGrid.BackgroundColor
        clrOld3 = CurrentGrid.BackgroundColor
        Me.BackColor = Color.White
        VoltageGrid.BackgroundColor = Color.LightGray
        CurrentGrid.BackgroundColor = Color.LightGray
        Me.Refresh()
        VoltageGrid.Refresh()
        CurrentGrid.Refresh()

        Dim psd As New PageSetupDialog
        psd.PrinterSettings = New System.Drawing.Printing.PrinterSettings
        psd.PageSettings = New System.Drawing.Printing.PageSettings

        'Sets up margins
        If psd.ShowDialog = Windows.Forms.DialogResult.OK Then
            If psd.PrinterSettings.IsValid Then
                PrintForm.PrinterSettings = psd.PrinterSettings
                PrintForm.PrinterSettings.DefaultPageSettings.Margins = New System.Drawing.Printing.Margins(psd.PageSettings.Margins.Left, psd.PageSettings.Margins.Right, psd.PageSettings.Margins.Top, psd.PageSettings.Margins.Bottom)
            End If
        End If

        'Prints page after viewing
        PrintForm.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
        psd.Dispose()

        'Restores form and grid background colors back to original
        Me.BackColor = clrOld1
        VoltageGrid.BackgroundColor = clrOld2
        CurrentGrid.BackgroundColor = clrOld3
        Me.Refresh()

Here are some screenshots:

CalProgramScreenShot 2.JPG CalProgram Print Preview.JPG

Any help you could provide me would be greatly appreciated. Thanks!
 
Top Bottom