我的表格的一部分没有出现在印刷品中

时间:2013-10-05 15:10:52

标签: vb.net

我想打印我的表单(除了Button控件之外的所有控件)。

但是我的表单中有一部分在我打印时不会出现。 如何让我的所有表格出现在纸上?

这是我的代码:

 Try
        Dim ctl As Control
        For Each ctl In Me.Controls
            If ctl.GetType.FullName = "System.Windows.Forms.Button" Then
                ctl.Visible = False
            End If
        Next
        'Before printing, set Form.BackColor as White
        Dim FormBackColor As Color = Me.BackColor
        Me.BackColor = System.Drawing.Color.White
        Me.Refresh()
        'Printing the form
        Dim PF As New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm
        PF.PrintAction = PrintAction.PrintToPreview
        PF.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
        'After printing, restore settings
        For Each ctl In Me.Controls
            If ctl.GetType.FullName = "System.Windows.Forms.Button" Then
                ctl.Visible = True
            End If
        Next
        Me.BackColor = FormBackColor

    Catch ex As Exception
        MsgBox(ex.Message.ToString)
    End Try 

0 个答案:

没有答案
相关问题