frmEasyPrint.vb
资源名称:GOLDPRINT.rar [点击查看]
上传用户:jx_fiona
上传日期:2014-03-08
资源大小:1387k
文件大小:11k
源码类别:
打印编程
开发平台:
Others
- '打印示例--简单快捷、易用实用
- Public Class frmEasyPrint
- Inherits System.Windows.Forms.Form
- #Region " Windows 窗体设计器生成的代码 "
- Public Sub New()
- MyBase.New()
- '该调用是 Windows 窗体设计器所必需的。
- InitializeComponent()
- '在 InitializeComponent() 调用之后添加任何初始化
- End Sub
- '窗体重写 dispose 以清理组件列表。
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Windows 窗体设计器所必需的
- Private components As System.ComponentModel.IContainer
- '注意: 以下过程是 Windows 窗体设计器所必需的
- '可以使用 Windows 窗体设计器修改此过程。
- '不要使用代码编辑器修改它。
- Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu
- Friend WithEvents menuFile As System.Windows.Forms.MenuItem
- Friend WithEvents menuFilePageSetup As System.Windows.Forms.MenuItem
- Friend WithEvents menuFilePrintPreview As System.Windows.Forms.MenuItem
- Friend WithEvents menuFilePrint As System.Windows.Forms.MenuItem
- Friend WithEvents menuFileExit As System.Windows.Forms.MenuItem
- Friend WithEvents menuOtherExamples As System.Windows.Forms.MenuItem
- Friend WithEvents menuEgCompletePrint As System.Windows.Forms.MenuItem
- Friend WithEvents menuEgExcel As System.Windows.Forms.MenuItem
- Friend WithEvents menuHelp As System.Windows.Forms.MenuItem
- Friend WithEvents menuHelpAbout As System.Windows.Forms.MenuItem
- Friend WithEvents dataGrid1 As System.Windows.Forms.DataGrid
- Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
- Friend WithEvents menuEgCasePrint As System.Windows.Forms.MenuItem
- Friend WithEvents menuVs2005DataGridViewPt As System.Windows.Forms.MenuItem
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.mainMenu1 = New System.Windows.Forms.MainMenu
- Me.menuFile = New System.Windows.Forms.MenuItem
- Me.menuFilePageSetup = New System.Windows.Forms.MenuItem
- Me.menuFilePrintPreview = New System.Windows.Forms.MenuItem
- Me.menuFilePrint = New System.Windows.Forms.MenuItem
- Me.menuFileExit = New System.Windows.Forms.MenuItem
- Me.menuOtherExamples = New System.Windows.Forms.MenuItem
- Me.menuEgCompletePrint = New System.Windows.Forms.MenuItem
- Me.menuEgExcel = New System.Windows.Forms.MenuItem
- Me.MenuItem1 = New System.Windows.Forms.MenuItem
- Me.menuEgCasePrint = New System.Windows.Forms.MenuItem
- Me.menuHelp = New System.Windows.Forms.MenuItem
- Me.menuHelpAbout = New System.Windows.Forms.MenuItem
- Me.dataGrid1 = New System.Windows.Forms.DataGrid
- Me.menuVs2005DataGridViewPt = New System.Windows.Forms.MenuItem
- CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'mainMenu1
- '
- Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuFile, Me.menuOtherExamples, Me.menuVs2005DataGridViewPt, Me.menuHelp})
- '
- 'menuFile
- '
- Me.menuFile.Index = 0
- Me.menuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuFilePageSetup, Me.menuFilePrintPreview, Me.menuFilePrint, Me.menuFileExit})
- Me.menuFile.Text = "文件(&F)"
- '
- 'menuFilePageSetup
- '
- Me.menuFilePageSetup.Index = 0
- Me.menuFilePageSetup.Text = "页面设置(&U)..."
- '
- 'menuFilePrintPreview
- '
- Me.menuFilePrintPreview.Index = 1
- Me.menuFilePrintPreview.Text = "打印预览(&V)"
- '
- 'menuFilePrint
- '
- Me.menuFilePrint.Index = 2
- Me.menuFilePrint.Text = "打印(&P)..."
- '
- 'menuFileExit
- '
- Me.menuFileExit.Index = 3
- Me.menuFileExit.Text = "退出(&X)"
- '
- 'menuOtherExamples
- '
- Me.menuOtherExamples.Index = 1
- Me.menuOtherExamples.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuEgCompletePrint, Me.menuEgExcel, Me.MenuItem1, Me.menuEgCasePrint})
- Me.menuOtherExamples.Text = "更多激动人心示例(完全示例、Excel、套打)(&E)"
- '
- 'menuEgCompletePrint
- '
- Me.menuEgCompletePrint.Index = 0
- Me.menuEgCompletePrint.Text = "对象定制变换无穷"
- '
- 'menuEgExcel
- '
- Me.menuEgExcel.Index = 1
- Me.menuEgExcel.Text = "Excel通打天下报表"
- '
- 'MenuItem1
- '
- Me.MenuItem1.Index = 2
- Me.MenuItem1.Text = "-"
- '
- 'menuEgCasePrint
- '
- Me.menuEgCasePrint.Index = 3
- Me.menuEgCasePrint.Text = "套打经典,国税发票"
- '
- 'menuHelp
- '
- Me.menuHelp.Index = 3
- Me.menuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuHelpAbout})
- Me.menuHelp.Text = "帮助(&H)"
- '
- 'menuHelpAbout
- '
- Me.menuHelpAbout.Index = 0
- Me.menuHelpAbout.Text = "关于 MIS金质打印通(&A)..."
- '
- 'dataGrid1
- '
- Me.dataGrid1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
- Or System.Windows.Forms.AnchorStyles.Left) _
- Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
- Me.dataGrid1.ColumnHeadersVisible = False
- Me.dataGrid1.DataMember = ""
- Me.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
- Me.dataGrid1.Location = New System.Drawing.Point(0, 0)
- Me.dataGrid1.Name = "dataGrid1"
- Me.dataGrid1.Size = New System.Drawing.Size(648, 373)
- Me.dataGrid1.TabIndex = 1
- '
- 'menuVs2005DataGridViewPt
- '
- Me.menuVs2005DataGridViewPt.Index = 2
- Me.menuVs2005DataGridViewPt.Text = "Vs2005DataGridView、ListView打印"
- '
- 'frmEasyPrint
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.ClientSize = New System.Drawing.Size(648, 374)
- Me.Controls.Add(Me.dataGrid1)
- Me.Menu = Me.mainMenu1
- Me.Name = "frmEasyPrint"
- Me.Text = "简单快捷、易用实用 -- MIS金质打印通 打印示例(VB版)"
- CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- '*****第一步*****:申明并实例化,可用带参构造函数指明默认横向显示/打印。
- '如果你不写完整的名字空间,请使用import GoldPrinter;
- Private misGoldPrinter As New GoldPrinter.MisGoldPrinter(True)
- '简单打印示例
- Private Sub Print(ByVal p_PrintOrPreview As Boolean)
- '*****第二步*****:直接赋值给打印对象(可选)
- ' 更精彩应用,请单击菜单 “更多激动人心示例对象定制变换无穷”
- misGoldPrinter.Title = "金质打印通 通打天下报表" + vbCrLf + "WWW.WebMIS.COM.CN" '主标题(vbCrLf表示换行)
- misGoldPrinter.Caption = " ——GoldPrinter,欢迎下载" '副标题
- misGoldPrinter.Top = "作者:周方勇|2004-08-19|版本:V2.5" '抬头,一行三列的文字说明,用|分隔
- misGoldPrinter.Bottom = "打印程序开源版||打印日期:" + System.DateTime.Now.ToLongDateString() '结尾,说明同抬头
- '*****第三步*****:打印重点,设置数据源
- '可以是一维数组、二维数组、DataGrid、DataTable、ListView、MshFlexGrid、HtmlTable...,
- '总之,不支持的你自己写一个函数转换成二维数组赋给DataSource一切搞定
- misGoldPrinter.DataSource = Me.dataGrid1 'DataGrid作为数据源
- '打印的核心是Body,可以对它设置字体、列宽等等
- CType(misGoldPrinter.Body, GoldPrinter.Body).IsAverageColsWidth = True '指明平均列宽
- '*****第四步*****:打印或预览
- If (p_PrintOrPreview) Then
- misGoldPrinter.Print() '打印
- Else
- misGoldPrinter.Preview() '预览
- End If
- End Sub
- Private Sub frmEasyPrint_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed
- '*****第五步*****:用完释放
- misGoldPrinter.Dispose()
- misGoldPrinter = Nothing
- End Sub
- '打印或预览 菜单:页面设置、打印机设置、打印预览
- Private Sub menuFilePageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuFilePageSetup.Click
- misGoldPrinter.PageSetup()
- End Sub
- Private Sub menuFilePrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuFilePrintPreview.Click
- Print(False)
- End Sub
- Private Sub menuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuFilePrint.Click
- Print(True)
- End Sub
- Private Sub menuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuFileExit.Click
- Application.Exit()
- End Sub
- '加载打印示例数据
- Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.dataGrid1.DataSource = PrintDataSource.GetDataSource(500)
- End Sub
- Private Sub menuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuHelpAbout.Click
- Dim frmInstance As New frmAbout
- frmInstance.ShowDialog()
- frmInstance.Dispose()
- End Sub
- Private Sub menuEgCompletePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuEgCompletePrint.Click
- Dim frmInstance As New frmCompletePrint
- frmInstance.ShowDialog()
- frmInstance.Dispose()
- End Sub
- Private Sub menuEgExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuEgExcel.Click
- Dim frmInstance As New frmExcelPrint
- frmInstance.ShowDialog()
- frmInstance.Dispose()
- End Sub
- Private Sub menuEgCasePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuEgCasePrint.Click
- Dim frmInstance As New frmInvoice
- frmInstance.ShowDialog()
- frmInstance.Dispose()
- End Sub
- Private Sub menuVs2005DataGridViewPt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuVs2005DataGridViewPt.Click
- Dim strMsg As String
- strMsg = "请见金质打印通工程 GoldPrintDataGridViewListViewHelper.cs说明。" + vbCrLf + "另参见 VS.NET打印思想与2003/5DataGrid、DataGridView及二维数据如ListView等终极打印实现。"
- MessageBox.Show(strMsg, "金质打印通 www.webmis.com.cn免费源码!")
- End Sub
- End Class