[VB.NET]vb中很容易实现的打印机设置窗口,在vb.net中如何实现?烦恼中!

前端之家收集整理的这篇文章主要介绍了[VB.NET]vb中很容易实现的打印机设置窗口,在vb.net中如何实现?烦恼中!前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
vb中很容易实现的打印机设置窗口,在vb.net中如何实现?烦恼中! vb中 只要用CommonDialog就可以调出打印机设置窗口,而vb.net中没有这个CommonDialog,想要参照comdlg32.dll,失败! 请问高手在vb.net中如何调出打印机设置窗口?并且能够保存住那些设置值? 要求跟vb中的打印机设置窗口一模一样! 谢谢了哦! __________________________________________________________________________ PageSetupDialog PrintDialog PrintDocument PrintPreviewControl PrintPreviewDialog 这些都和打印有关,你可以通过PageSetupDialog及PrintDialog来做像以前的CommonDialog的功能! __________________________________________________________________________ PageSetupDialog:是页面设置,虽然里面也有打印机设置,但是要求调出来的直接是打印机设置窗口! PrintDialog:印刷设定 理由同上! __________________________________________________________________________ Dim pPrint As New PrintDialog pPrint.AllowCurrentPage = False pPrint.AllowPrintToFile = False pPrint.AllowSelection = False pPrint.AllowSomePages = False pDocument.DocumentName = "支票 " pPrint.Document = pDocument If pPrint.ShowDialog() = Windows.Forms.DialogResult.OK Then Dim pPreview As New PrintPreviewDialog pPreview.Document = pDocument pPreview.ShowDialog() End If __________________________________________________________________________ 用PrintPreviewControl控件自己做一个Dialog :) __________________________________________________________________________ 最后是通过重构api函数实现的,谢谢各位啊! __________________________________________________________________________ Public Function ShowPrinter() As DialogResult ''显示打印机设置窗口 Dim pd As New PrintDialog Dim eRtn As DialogResult Try pd.AllowPrintToFile = False pd.AllowSelection = False pd.AllowSomePages = False pd.Document = _PrtDoc pd.PrintToFile = False pd.ShowHelp = False pd.ShowNetwork = False eRtn = pd.ShowDialog If eRtn = DialogResult.OK Then _PrtSet = pd.PrinterSettings End If Catch ex As Exception eRtn = DialogResult.Cancel End Try pd.Dispose() pd = Nothing Return eRtn End Function Public Function ShowPageSetup() As DialogResult ''显示页面设置窗口 Dim ps As New PageSetupDialog Dim eRtn As DialogResult Try ps.Document = _PrtDoc ps.AllowMargins = False ps.AllowPrinter = False eRtn = ps.ShowDialog() If eRtn = DialogResult.OK Then _PrtPage = ps.PageSettings End If Catch ex As Exception eRtn = DialogResult.Cancel End Try ps.Dispose() ps = Nothing Return eRtn End Function Public Sub ShowPreview() ''显示预览窗口 Dim prev As New PrintPreviewDialog Try prev.Document = _PrtDoc prev.WindowState = FormWindowState.Maximized prev.UseAntiAlias = True prev.ShowInTaskbar = True prev.Name = "打印预览 " prev.ShowDialog() Catch ex As Exception End Try prev.Close() prev.Dispose() prev = Nothing End Sub __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263780.html

猜你在找的VB相关文章