0

フォームを印刷したい (コントロールを除くすべての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 
4

0 に答える 0