我创建了一个用于计算HVAC设备的应用程序。一切都好(My last question in this app),但我面临一个新问题。当我单击打印按钮然后选择打印机时,打印预览对话框会显示打印机选择对话框的跟踪。
我尝试了不同行的睡眠功能,但它不起作用。 我该如何修复我的应用? 这是我的代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Button1.Visible = False
ComboBox1.Visible = False
PrintDialog1.PrinterSettings = PrintForm1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = DialogResult.OK Then
Thread.Sleep(3000)
With Me.PrintForm1
PrintForm1.PrinterSettings = PrintDialog1.PrinterSettings
.PrintAction = Printing.PrintAction.PrintToPreview
Dim MyMargins As New Margins
With MyMargins
.Left = 40
.Right = 40
.Top = 40
.Bottom = 40
End With
.PrinterSettings.DefaultPageSettings.Margins = MyMargins
PrintForm1.DocumentName = notasyon_lbl.Text
.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)
End With
End If
Me.Close()
End Sub