我想打印我的表单(除控件外的所有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