使用打印表单组件选择打印机和设置页边距 [英] Selecting printer and settings margins of page with printform component
本文介绍了使用打印表单组件选择打印机和设置页边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何添加打印机选择对话框,以及如何控制页面边距?我在代码中尝试了很多东西(printdocument 代码有效,但它们不显示我的表单)但它们不起作用.我正在使用此代码打印表单:
How can I add printer selection dialog, and how can I control margins of a page? I tried so many things in code (printdocument codes works but they don't show my form) but they did not work. I'm using this code to print form:
With Me.PrintForm1
.PrintAction = Printing.PrintAction.PrintToPreview
.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
End With
Me.Close()
它正在工作,但它不会要求选择打印机,而且我无法控制边距.
It's working but, it does not asks for printer selection and I can't control margins.
谢谢
推荐答案
我终于找到了解决方案,它是:
I found the solution finally, here it is:
PrintDialog1.PrinterSettings = PrintForm1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = DialogResult.OK Then
PrintForm1.PrinterSettings = PrintDialog1.PrinterSettings
With Me.PrintForm1
.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
还是谢谢.
这篇关于使用打印表单组件选择打印机和设置页边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文