在好例子网,分享、交流、成长!
您当前所在位置:首页ASP 开发实例VB编程 → winform 以报表方式打印表单

winform 以报表方式打印表单

VB编程

下载此实例
  • 开发语言:ASP
  • 实例大小:0.08M
  • 下载次数:26
  • 浏览次数:431
  • 发布时间:2019-01-18
  • 实例类别:VB编程
  • 发 布 人:wangserd
  • 文件格式:.zip
  • 所需积分:2
 相关标签: 打印 报表 表单

实例介绍

【实例简介】

【实例截图】

from clipboard


from clipboardfrom clipboard


from clipboard


from clipboard

【核心代码】

Public Class DemoForm
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	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

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
	Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
	Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
	Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
	Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents Button1 As System.Windows.Forms.Button
	Friend WithEvents ButtonPrintMe As System.Windows.Forms.Button
	Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
	Friend WithEvents Panel1 As System.Windows.Forms.Panel
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
	Friend WithEvents Label5Hide As System.Windows.Forms.Label
	Friend WithEvents Label5 As System.Windows.Forms.Label
	Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
	Friend WithEvents Label6 As System.Windows.Forms.Label
	Friend WithEvents Label7 As System.Windows.Forms.Label
	Friend WithEvents Label8 As System.Windows.Forms.Label
	Friend WithEvents Label9 As System.Windows.Forms.Label
	Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents CheckBoxTextBoxBoxed As System.Windows.Forms.CheckBox
	Friend WithEvents CheckBoxTabControlBoxed As System.Windows.Forms.CheckBox
	Friend WithEvents CheckBoxLabelInBold As System.Windows.Forms.CheckBox
	Friend WithEvents RadioButtonPortrait As System.Windows.Forms.RadioButton
	Friend WithEvents RadioButtonLandscape As System.Windows.Forms.RadioButton
	Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
	Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents Panel2 As System.Windows.Forms.Panel
	Friend WithEvents Label10 As System.Windows.Forms.Label
	Friend WithEvents Panel3 As System.Windows.Forms.Panel
	Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
	Friend WithEvents Label11 As System.Windows.Forms.Label
	Friend WithEvents Label12 As System.Windows.Forms.Label
	Friend WithEvents CheckBoxDisabledControlsInGray As System.Windows.Forms.CheckBox
	Friend WithEvents RadioButtonAutomatic As System.Windows.Forms.RadioButton
	Friend WithEvents Label13 As System.Windows.Forms.Label
	Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
	Friend WithEvents NumericUpDown2 As System.Windows.Forms.NumericUpDown
	Friend WithEvents TabPage4 As System.Windows.Forms.TabPage
	Friend WithEvents NumericUpDown3 As System.Windows.Forms.NumericUpDown
	Friend WithEvents Label14 As System.Windows.Forms.Label
	Friend WithEvents ListBox3 As System.Windows.Forms.ListBox
	Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
	Friend WithEvents CheckBoxPageNumbering As System.Windows.Forms.CheckBox
	Friend WithEvents CheckBoxPrintPreview As System.Windows.Forms.CheckBox
	Friend WithEvents DataGrid As System.Windows.Forms.DataGrid
	Friend WithEvents NumericUpDown4 As System.Windows.Forms.NumericUpDown
	Friend WithEvents ButtonTrace As System.Windows.Forms.Button
	Friend WithEvents ButtonTif As System.Windows.Forms.Button
	Friend WithEvents CheckBoxMyOwn As System.Windows.Forms.CheckBox
	Friend WithEvents ButtonPrintTab As System.Windows.Forms.Button
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(DemoForm))
		Me.Label1 = New System.Windows.Forms.Label
		Me.TextBox1 = New System.Windows.Forms.TextBox
		Me.TabControl1 = New System.Windows.Forms.TabControl
		Me.TabPage1 = New System.Windows.Forms.TabPage
		Me.Label7 = New System.Windows.Forms.Label
		Me.ComboBox1 = New System.Windows.Forms.ComboBox
		Me.Label5 = New System.Windows.Forms.Label
		Me.Button1 = New System.Windows.Forms.Button
		Me.TextBox2 = New System.Windows.Forms.TextBox
		Me.Label2 = New System.Windows.Forms.Label
		Me.TabPage2 = New System.Windows.Forms.TabPage
		Me.NumericUpDown3 = New System.Windows.Forms.NumericUpDown
		Me.Label14 = New System.Windows.Forms.Label
		Me.ListBox3 = New System.Windows.Forms.ListBox
		Me.NumericUpDown2 = New System.Windows.Forms.NumericUpDown
		Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
		Me.Label13 = New System.Windows.Forms.Label
		Me.Label12 = New System.Windows.Forms.Label
		Me.Label11 = New System.Windows.Forms.Label
		Me.ListBox2 = New System.Windows.Forms.ListBox
		Me.ListBox1 = New System.Windows.Forms.ListBox
		Me.Panel3 = New System.Windows.Forms.Panel
		Me.TabPage4 = New System.Windows.Forms.TabPage
		Me.NumericUpDown4 = New System.Windows.Forms.NumericUpDown
		Me.DataGrid = New System.Windows.Forms.DataGrid
		Me.TabPage3 = New System.Windows.Forms.TabPage
		Me.Panel2 = New System.Windows.Forms.Panel
		Me.Label10 = New System.Windows.Forms.Label
		Me.Label3 = New System.Windows.Forms.Label
		Me.PictureBox1 = New System.Windows.Forms.PictureBox
		Me.ButtonPrintMe = New System.Windows.Forms.Button
		Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
		Me.Panel1 = New System.Windows.Forms.Panel
		Me.Label6 = New System.Windows.Forms.Label
		Me.Label5Hide = New System.Windows.Forms.Label
		Me.Label4 = New System.Windows.Forms.Label
		Me.TextBox4 = New System.Windows.Forms.TextBox
		Me.Label8 = New System.Windows.Forms.Label
		Me.Label9 = New System.Windows.Forms.Label
		Me.GroupBox1 = New System.Windows.Forms.GroupBox
		Me.ButtonPrintTab = New System.Windows.Forms.Button
		Me.CheckBoxMyOwn = New System.Windows.Forms.CheckBox
		Me.ButtonTif = New System.Windows.Forms.Button
		Me.ButtonTrace = New System.Windows.Forms.Button
		Me.CheckBoxPrintPreview = New System.Windows.Forms.CheckBox
		Me.RadioButtonAutomatic = New System.Windows.Forms.RadioButton
		Me.RadioButtonLandscape = New System.Windows.Forms.RadioButton
		Me.RadioButtonPortrait = New System.Windows.Forms.RadioButton
		Me.CheckBoxPageNumbering = New System.Windows.Forms.CheckBox
		Me.CheckBoxLabelInBold = New System.Windows.Forms.CheckBox
		Me.CheckBoxDisabledControlsInGray = New System.Windows.Forms.CheckBox
		Me.CheckBoxTabControlBoxed = New System.Windows.Forms.CheckBox
		Me.CheckBoxTextBoxBoxed = New System.Windows.Forms.CheckBox
		Me.TabControl1.SuspendLayout()
		Me.TabPage1.SuspendLayout()
		Me.TabPage2.SuspendLayout()
		CType(Me.NumericUpDown3, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.TabPage4.SuspendLayout()
		CType(Me.NumericUpDown4, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.DataGrid, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.TabPage3.SuspendLayout()
		Me.Panel2.SuspendLayout()
		Me.Panel1.SuspendLayout()
		Me.GroupBox1.SuspendLayout()
		Me.SuspendLayout()
		'
		'Label1
		'
		Me.Label1.Location = New System.Drawing.Point(16, 8)
		Me.Label1.Name = "Label1"
		Me.Label1.TabIndex = 0
		Me.Label1.Text = "Name :"
		'
		'TextBox1
		'
		Me.TextBox1.Location = New System.Drawing.Point(152, 8)
		Me.TextBox1.Multiline = True
		Me.TextBox1.Name = "TextBox1"
		Me.TextBox1.Size = New System.Drawing.Size(216, 20)
		Me.TextBox1.TabIndex = 1
		Me.TextBox1.Text = "TextBox1   (multi-lines)"
		'
		'TabControl1
		'
		Me.TabControl1.Controls.Add(Me.TabPage1)
		Me.TabControl1.Controls.Add(Me.TabPage2)
		Me.TabControl1.Controls.Add(Me.TabPage4)
		Me.TabControl1.Controls.Add(Me.TabPage3)
		Me.TabControl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.TabControl1.ItemSize = New System.Drawing.Size(62, 30)
		Me.TabControl1.Location = New System.Drawing.Point(16, 40)
		Me.TabControl1.Name = "TabControl1"
		Me.TabControl1.SelectedIndex = 0
		Me.TabControl1.Size = New System.Drawing.Size(400, 152)
		Me.TabControl1.TabIndex = 2
		'
		'TabPage1
		'
		Me.TabPage1.Controls.Add(Me.Label7)
		Me.TabPage1.Controls.Add(Me.ComboBox1)
		Me.TabPage1.Controls.Add(Me.Label5)
		Me.TabPage1.Controls.Add(Me.Button1)
		Me.TabPage1.Controls.Add(Me.TextBox2)
		Me.TabPage1.Controls.Add(Me.Label2)
		Me.TabPage1.Location = New System.Drawing.Point(4, 34)
		Me.TabPage1.Name = "TabPage1"
		Me.TabPage1.Size = New System.Drawing.Size(392, 114)
		Me.TabPage1.TabIndex = 0
		Me.TabPage1.Text = "Alignment"
		'
		'Label7
		'
		Me.Label7.Location = New System.Drawing.Point(8, 40)
		Me.Label7.Name = "Label7"
		Me.Label7.Size = New System.Drawing.Size(112, 23)
		Me.Label7.TabIndex = 7
		Me.Label7.Text = "Item:"
		Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'ComboBox1
		'
		Me.ComboBox1.Items.AddRange(New Object() {"first item", "second item", "third item"})
		Me.ComboBox1.Location = New System.Drawing.Point(128, 40)
		Me.ComboBox1.Name = "ComboBox1"
		Me.ComboBox1.Size = New System.Drawing.Size(152, 21)
		Me.ComboBox1.TabIndex = 6
		Me.ComboBox1.Text = "ComboBox1"
		'
		'Label5
		'
		Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label5.Location = New System.Drawing.Point(16, 72)
		Me.Label5.Name = "Label5"
		Me.Label5.Size = New System.Drawing.Size(360, 23)
		Me.Label5.TabIndex = 5
		Me.Label5.Text = "Label5 - Centered"
		Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
		'
		'Button1
		'
		Me.Button1.Location = New System.Drawing.Point(296, 40)
		Me.Button1.Name = "Button1"
		Me.Button1.TabIndex = 4
		Me.Button1.Text = "Button1"
		'
		'TextBox2
		'
		Me.TextBox2.Location = New System.Drawing.Point(128, 8)
		Me.TextBox2.Name = "TextBox2"
		Me.TextBox2.Size = New System.Drawing.Size(248, 20)
		Me.TextBox2.TabIndex = 3
		Me.TextBox2.Text = "TextBox2 - RightAlign"
		Me.TextBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
		'
		'Label2
		'
		Me.Label2.Location = New System.Drawing.Point(8, 8)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(112, 23)
		Me.Label2.TabIndex = 2
		Me.Label2.Text = "Name 1 Right:"
		Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'TabPage2
		'
		Me.TabPage2.Controls.Add(Me.NumericUpDown3)
		Me.TabPage2.Controls.Add(Me.Label14)
		Me.TabPage2.Controls.Add(Me.ListBox3)
		Me.TabPage2.Controls.Add(Me.NumericUpDown2)
		Me.TabPage2.Controls.Add(Me.NumericUpDown1)
		Me.TabPage2.Controls.Add(Me.Label13)
		Me.TabPage2.Controls.Add(Me.Label12)
		Me.TabPage2.Controls.Add(Me.Label11)
		Me.TabPage2.Controls.Add(Me.ListBox2)
		Me.TabPage2.Controls.Add(Me.ListBox1)
		Me.TabPage2.Controls.Add(Me.Panel3)
		Me.TabPage2.Location = New System.Drawing.Point(4, 34)
		Me.TabPage2.Name = "TabPage2"
		Me.TabPage2.Size = New System.Drawing.Size(392, 114)
		Me.TabPage2.TabIndex = 1
		Me.TabPage2.Text = "ListBox Sample"
		'
		'NumericUpDown3
		'
		Me.NumericUpDown3.Location = New System.Drawing.Point(328, 88)
		Me.NumericUpDown3.Name = "NumericUpDown3"
		Me.NumericUpDown3.Size = New System.Drawing.Size(40, 20)
		Me.NumericUpDown3.TabIndex = 22
		Me.NumericUpDown3.Value = New Decimal(New Integer() {10, 0, 0, 0})
		'
		'Label14
		'
		Me.Label14.Font = New System.Drawing.Font("Comic Sans MS", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label14.Location = New System.Drawing.Point(184, 64)
		Me.Label14.Name = "Label14"
		Me.Label14.Size = New System.Drawing.Size(16, 23)
		Me.Label14.TabIndex = 21
		Me.Label14.Text = "3"
		'
		'ListBox3
		'
		Me.ListBox3.Location = New System.Drawing.Point(208, 64)
		Me.ListBox3.Name = "ListBox3"
		Me.ListBox3.Size = New System.Drawing.Size(112, 43)
		Me.ListBox3.TabIndex = 20
		'
		'NumericUpDown2
		'
		Me.NumericUpDown2.Location = New System.Drawing.Point(136, 88)
		Me.NumericUpDown2.Name = "NumericUpDown2"
		Me.NumericUpDown2.Size = New System.Drawing.Size(40, 20)
		Me.NumericUpDown2.TabIndex = 19
		Me.NumericUpDown2.Value = New Decimal(New Integer() {40, 0, 0, 0})
		'
		'NumericUpDown1
		'
		Me.NumericUpDown1.Location = New System.Drawing.Point(224, 32)
		Me.NumericUpDown1.Name = "NumericUpDown1"
		Me.NumericUpDown1.Size = New System.Drawing.Size(40, 20)
		Me.NumericUpDown1.TabIndex = 18
		Me.NumericUpDown1.Value = New Decimal(New Integer() {40, 0, 0, 0})
		'
		'Label13
		'
		Me.Label13.Location = New System.Drawing.Point(224, 8)
		Me.Label13.Name = "Label13"
		Me.Label13.Size = New System.Drawing.Size(160, 23)
		Me.Label13.TabIndex = 17
		Me.Label13.Text = "Set  number of items in list box"
		'
		'Label12
		'
		Me.Label12.Font = New System.Drawing.Font("Comic Sans MS", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label12.Location = New System.Drawing.Point(0, 64)
		Me.Label12.Name = "Label12"
		Me.Label12.Size = New System.Drawing.Size(16, 23)
		Me.Label12.TabIndex = 16
		Me.Label12.Text = "2"
		'
		'Label11
		'
		Me.Label11.Font = New System.Drawing.Font("Comic Sans MS", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label11.Location = New System.Drawing.Point(0, 8)
		Me.Label11.Name = "Label11"
		Me.Label11.Size = New System.Drawing.Size(16, 23)
		Me.Label11.TabIndex = 15
		Me.Label11.Text = "1"
		'
		'ListBox2
		'
		Me.ListBox2.Location = New System.Drawing.Point(24, 64)
		Me.ListBox2.Name = "ListBox2"
		Me.ListBox2.Size = New System.Drawing.Size(104, 43)
		Me.ListBox2.TabIndex = 14
		'
		'ListBox1
		'
		Me.ListBox1.Location = New System.Drawing.Point(24, 8)
		Me.ListBox1.Name = "ListBox1"
		Me.ListBox1.Size = New System.Drawing.Size(192, 43)
		Me.ListBox1.TabIndex = 13
		'
		'Panel3
		'
		Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
		Me.Panel3.Location = New System.Drawing.Point(8, 56)
		Me.Panel3.Name = "Panel3"
		Me.Panel3.Size = New System.Drawing.Size(376, 2)
		Me.Panel3.TabIndex = 14
		'
		'TabPage4
		'
		Me.TabPage4.Controls.Add(Me.NumericUpDown4)
		Me.TabPage4.Controls.Add(Me.DataGrid)
		Me.TabPage4.Location = New System.Drawing.Point(4, 34)
		Me.TabPage4.Name = "TabPage4"
		Me.TabPage4.Size = New System.Drawing.Size(392, 114)
		Me.TabPage4.TabIndex = 3
		Me.TabPage4.Text = "DataGrid Sample"
		'
		'NumericUpDown4
		'
		Me.NumericUpDown4.Location = New System.Drawing.Point(344, 80)
		Me.NumericUpDown4.Maximum = New Decimal(New Integer() {10000, 0, 0, 0})
		Me.NumericUpDown4.Minimum = New Decimal(New Integer() {1, 0, 0, 0})
		Me.NumericUpDown4.Name = "NumericUpDown4"
		Me.NumericUpDown4.Size = New System.Drawing.Size(40, 20)
		Me.NumericUpDown4.TabIndex = 23
		Me.NumericUpDown4.Value = New Decimal(New Integer() {10, 0, 0, 0})
		'
		'DataGrid
		'
		Me.DataGrid.DataMember = ""
		Me.DataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText
		Me.DataGrid.Location = New System.Drawing.Point(8, 8)
		Me.DataGrid.Name = "DataGrid"
		Me.DataGrid.Size = New System.Drawing.Size(328, 96)
		Me.DataGrid.TabIndex = 0
		'
		'TabPage3
		'
		Me.TabPage3.Controls.Add(Me.Panel2)
		Me.TabPage3.Controls.Add(Me.Label3)
		Me.TabPage3.Controls.Add(Me.PictureBox1)
		Me.TabPage3.Location = New System.Drawing.Point(4, 34)
		Me.TabPage3.Name = "TabPage3"
		Me.TabPage3.Size = New System.Drawing.Size(392, 114)
		Me.TabPage3.TabIndex = 2
		Me.TabPage3.Text = "FlexGrid Sample"
		'
		'Panel2
		'
		Me.Panel2.Controls.Add(Me.Label10)
		Me.Panel2.Location = New System.Drawing.Point(8, 24)
		Me.Panel2.Name = "Panel2"
		Me.Panel2.Size = New System.Drawing.Size(264, 80)
		Me.Panel2.TabIndex = 2
		'
		'Label10
		'
		Me.Label10.Enabled = False
		Me.Label10.Location = New System.Drawing.Point(16, 16)
		Me.Label10.Name = "Label10"
		Me.Label10.Size = New System.Drawing.Size(248, 40)
		Me.Label10.TabIndex = 0
		Me.Label10.Text = "FlexGrid Removed in this Demo because reference could not be loaded on other comp" & _
		"uter."
		'
		'Label3
		'
		Me.Label3.Location = New System.Drawing.Point(8, 8)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(256, 23)
		Me.Label3.TabIndex = 1
		Me.Label3.Text = "(flexGrid form Component One)"
		'
		'PictureBox1
		'
		Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
		Me.PictureBox1.Location = New System.Drawing.Point(288, 40)
		Me.PictureBox1.Name = "PictureBox1"
		Me.PictureBox1.Size = New System.Drawing.Size(96, 64)
		Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
		Me.PictureBox1.TabIndex = 13
		Me.PictureBox1.TabStop = False
		'
		'ButtonPrintMe
		'
		Me.ButtonPrintMe.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.ButtonPrintMe.ForeColor = System.Drawing.SystemColors.Highlight
		Me.ButtonPrintMe.Location = New System.Drawing.Point(16, 24)
		Me.ButtonPrintMe.Name = "ButtonPrintMe"
		Me.ButtonPrintMe.Size = New System.Drawing.Size(96, 24)
		Me.ButtonPrintMe.TabIndex = 4
		Me.ButtonPrintMe.Text = "Print me"
		'
		'DateTimePicker1
		'
		Me.DateTimePicker1.Location = New System.Drawing.Point(56, 200)
		Me.DateTimePicker1.Name = "DateTimePicker1"
		Me.DateTimePicker1.Size = New System.Drawing.Size(160, 20)
		Me.DateTimePicker1.TabIndex = 7
		'
		'Panel1
		'
		Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
		Me.Panel1.Controls.Add(Me.Label6)
		Me.Panel1.Controls.Add(Me.Label5Hide)
		Me.Panel1.Controls.Add(Me.Label4)
		Me.Panel1.Enabled = False
		Me.Panel1.Location = New System.Drawing.Point(224, 200)
		Me.Panel1.Name = "Panel1"
		Me.Panel1.Size = New System.Drawing.Size(192, 96)
		Me.Panel1.TabIndex = 8
		'
		'Label6
		'
		Me.Label6.Location = New System.Drawing.Point(24, 56)
		Me.Label6.Name = "Label6"
		Me.Label6.Size = New System.Drawing.Size(122, 32)
		Me.Label6.TabIndex = 2
		Me.Label6.Text = "Label4 with more than one line of text"
		'
		'Label5Hide
		'
		Me.Label5Hide.Location = New System.Drawing.Point(24, 32)
		Me.Label5Hide.Name = "Label5Hide"
		Me.Label5Hide.TabIndex = 1
		Me.Label5Hide.Text = "Label5Hidden"
		Me.Label5Hide.Visible = False
		'
		'Label4
		'
		Me.Label4.Location = New System.Drawing.Point(24, 8)
		Me.Label4.Name = "Label4"
		Me.Label4.Size = New System.Drawing.Size(152, 23)
		Me.Label4.TabIndex = 0
		Me.Label4.Text = "Label4 in disabled panel"
		'
		'TextBox4
		'
		Me.TextBox4.Location = New System.Drawing.Point(56, 224)
		Me.TextBox4.Multiline = True
		Me.TextBox4.Name = "TextBox4"
		Me.TextBox4.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
		Me.TextBox4.Size = New System.Drawing.Size(160, 72)
		Me.TextBox4.TabIndex = 9
		Me.TextBox4.Text = "TextBox4 multiline with more than one line"
		'
		'Label8
		'
		Me.Label8.Location = New System.Drawing.Point(16, 200)
		Me.Label8.Name = "Label8"
		Me.Label8.Size = New System.Drawing.Size(112, 23)
		Me.Label8.TabIndex = 10
		Me.Label8.Text = "Date:"
		Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
		'
		'Label9
		'
		Me.Label9.Location = New System.Drawing.Point(16, 224)
		Me.Label9.Name = "Label9"
		Me.Label9.Size = New System.Drawing.Size(112, 23)
		Me.Label9.TabIndex = 11
		Me.Label9.Text = "Note:"
		Me.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
		'
		'GroupBox1
		'
		Me.GroupBox1.Controls.Add(Me.ButtonPrintTab)
		Me.GroupBox1.Controls.Add(Me.CheckBoxMyOwn)
		Me.GroupBox1.Controls.Add(Me.ButtonTif)
		Me.GroupBox1.Controls.Add(Me.ButtonTrace)
		Me.GroupBox1.Controls.Add(Me.CheckBoxPrintPreview)
		Me.GroupBox1.Controls.Add(Me.RadioButtonAutomatic)
		Me.GroupBox1.Controls.Add(Me.RadioButtonLandscape)
		Me.GroupBox1.Controls.Add(Me.RadioButtonPortrait)
		Me.GroupBox1.Controls.Add(Me.CheckBoxPageNumbering)
		Me.GroupBox1.Controls.Add(Me.CheckBoxLabelInBold)
		Me.GroupBox1.Controls.Add(Me.CheckBoxDisabledControlsInGray)
		Me.GroupBox1.Controls.Add(Me.CheckBoxTabControlBoxed)
		Me.GroupBox1.Controls.Add(Me.CheckBoxTextBoxBoxed)
		Me.GroupBox1.Controls.Add(Me.ButtonPrintMe)
		Me.GroupBox1.Location = New System.Drawing.Point(8, 304)
		Me.GroupBox1.Name = "GroupBox1"
		Me.GroupBox1.Size = New System.Drawing.Size(408, 144)
		Me.GroupBox1.TabIndex = 13
		Me.GroupBox1.TabStop = False
		Me.GroupBox1.Text = "Print Me - Choose options..."
		'
		'ButtonPrintTab
		'
		Me.ButtonPrintTab.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.ButtonPrintTab.ForeColor = System.Drawing.SystemColors.Highlight
		Me.ButtonPrintTab.Location = New System.Drawing.Point(16, 72)
		Me.ButtonPrintTab.Name = "ButtonPrintTab"
		Me.ButtonPrintTab.Size = New System.Drawing.Size(96, 24)
		Me.ButtonPrintTab.TabIndex = 18
		Me.ButtonPrintTab.Text = "Print Tab"
		'
		'CheckBoxMyOwn
		'
		Me.CheckBoxMyOwn.Location = New System.Drawing.Point(152, 104)
		Me.CheckBoxMyOwn.Name = "CheckBoxMyOwn"
		Me.CheckBoxMyOwn.Size = New System.Drawing.Size(232, 16)
		Me.CheckBoxMyOwn.TabIndex = 16
		Me.CheckBoxMyOwn.Text = "Use my Own function to print report title"
		'
		'ButtonTif
		'
		Me.ButtonTif.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.ButtonTif.ForeColor = System.Drawing.SystemColors.Highlight
		Me.ButtonTif.Location = New System.Drawing.Point(16, 48)
		Me.ButtonTif.Name = "ButtonTif"
		Me.ButtonTif.Size = New System.Drawing.Size(96, 24)
		Me.ButtonTif.TabIndex = 15
		Me.ButtonTif.Text = """Tif"" me"
		'
		'ButtonTrace
		'
		Me.ButtonTrace.Enabled = False
		Me.ButtonTrace.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.ButtonTrace.ForeColor = System.Drawing.SystemColors.Highlight
		Me.ButtonTrace.Location = New System.Drawing.Point(16, 112)
		Me.ButtonTrace.Name = "ButtonTrace"
		Me.ButtonTrace.Size = New System.Drawing.Size(96, 24)
		Me.ButtonTrace.TabIndex = 14
		Me.ButtonTrace.Text = "Trace"
		'
		'CheckBoxPrintPreview
		'
		Me.CheckBoxPrintPreview.Checked = True
		Me.CheckBoxPrintPreview.CheckState = System.Windows.Forms.CheckState.Checked
		Me.CheckBoxPrintPreview.Location = New System.Drawing.Point(152, 120)
		Me.CheckBoxPrintPreview.Name = "CheckBoxPrintPreview"
		Me.CheckBoxPrintPreview.Size = New System.Drawing.Size(96, 15)
		Me.CheckBoxPrintPreview.TabIndex = 13
		Me.CheckBoxPrintPreview.Text = "Print Preview"
		'
		'RadioButtonAutomatic
		'
		Me.RadioButtonAutomatic.Checked = True
		Me.RadioButtonAutomatic.Location = New System.Drawing.Point(304, 56)
		Me.RadioButtonAutomatic.Name = "RadioButtonAutomatic"
		Me.RadioButtonAutomatic.Size = New System.Drawing.Size(80, 15)
		Me.RadioButtonAutomatic.TabIndex = 12
		Me.RadioButtonAutomatic.TabStop = True
		Me.RadioButtonAutomatic.Text = "Automatic"
		'
		'RadioButtonLandscape
		'
		Me.RadioButtonLandscape.Location = New System.Drawing.Point(304, 40)
		Me.RadioButtonLandscape.Name = "RadioButtonLandscape"
		Me.RadioButtonLandscape.Size = New System.Drawing.Size(80, 15)
		Me.RadioButtonLandscape.TabIndex = 10
		Me.RadioButtonLandscape.Text = "Landscape"
		'
		'RadioButtonPortrait
		'
		Me.RadioButtonPortrait.Location = New System.Drawing.Point(304, 24)
		Me.RadioButtonPortrait.Name = "RadioButtonPortrait"
		Me.RadioButtonPortrait.Size = New System.Drawing.Size(72, 15)
		Me.RadioButtonPortrait.TabIndex = 9
		Me.RadioButtonPortrait.Text = "Portrait"
		'
		'CheckBoxPageNumbering
		'
		Me.CheckBoxPageNumbering.Checked = True
		Me.CheckBoxPageNumbering.CheckState = System.Windows.Forms.CheckState.Checked
		Me.CheckBoxPageNumbering.Location = New System.Drawing.Point(152, 88)
		Me.CheckBoxPageNumbering.Name = "CheckBoxPageNumbering"
		Me.CheckBoxPageNumbering.Size = New System.Drawing.Size(112, 16)
		Me.CheckBoxPageNumbering.TabIndex = 8
		Me.CheckBoxPageNumbering.Text = "Page numbering"
		'
		'CheckBoxLabelInBold
		'
		Me.CheckBoxLabelInBold.Checked = True
		Me.CheckBoxLabelInBold.CheckState = System.Windows.Forms.CheckState.Checked
		Me.CheckBoxLabelInBold.Location = New System.Drawing.Point(152, 72)
		Me.CheckBoxLabelInBold.Name = "CheckBoxLabelInBold"
		Me.CheckBoxLabelInBold.Size = New System.Drawing.Size(104, 15)
		Me.CheckBoxLabelInBold.TabIndex = 7
		Me.CheckBoxLabelInBold.Text = "Label in bold"
		'
		'CheckBoxDisabledControlsInGray
		'
		Me.CheckBoxDisabledControlsInGray.Location = New System.Drawing.Point(152, 56)
		Me.CheckBoxDisabledControlsInGray.Name = "CheckBoxDisabledControlsInGray"
		Me.CheckBoxDisabledControlsInGray.Size = New System.Drawing.Size(152, 15)
		Me.CheckBoxDisabledControlsInGray.TabIndex = 11
		Me.CheckBoxDisabledControlsInGray.Text = "Disabled controls in gray"
		'
		'CheckBoxTabControlBoxed
		'
		Me.CheckBoxTabControlBoxed.Checked = True
		Me.CheckBoxTabControlBoxed.CheckState = System.Windows.Forms.CheckState.Checked
		Me.CheckBoxTabControlBoxed.Location = New System.Drawing.Point(152, 40)
		Me.CheckBoxTabControlBoxed.Name = "CheckBoxTabControlBoxed"
		Me.CheckBoxTabControlBoxed.Size = New System.Drawing.Size(120, 15)
		Me.CheckBoxTabControlBoxed.TabIndex = 6
		Me.CheckBoxTabControlBoxed.Text = "TabControl Boxed"
		'
		'CheckBoxTextBoxBoxed
		'
		Me.CheckBoxTextBoxBoxed.Location = New System.Drawing.Point(152, 24)
		Me.CheckBoxTextBoxBoxed.Name = "CheckBoxTextBoxBoxed"
		Me.CheckBoxTextBoxBoxed.Size = New System.Drawing.Size(104, 15)
		Me.CheckBoxTextBoxBoxed.TabIndex = 5
		Me.CheckBoxTextBoxBoxed.Text = "TextBox Boxed"
		'
		'DemoForm
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(432, 453)
		Me.Controls.Add(Me.GroupBox1)
		Me.Controls.Add(Me.TextBox4)
		Me.Controls.Add(Me.TextBox1)
		Me.Controls.Add(Me.Panel1)
		Me.Controls.Add(Me.DateTimePicker1)
		Me.Controls.Add(Me.TabControl1)
		Me.Controls.Add(Me.Label1)
		Me.Controls.Add(Me.Label8)
		Me.Controls.Add(Me.Label9)
		Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
		Me.Name = "DemoForm"
		Me.Text = "This is my test Form"
		Me.TabControl1.ResumeLayout(False)
		Me.TabPage1.ResumeLayout(False)
		Me.TabPage2.ResumeLayout(False)
		CType(Me.NumericUpDown3, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.NumericUpDown2, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
		Me.TabPage4.ResumeLayout(False)
		CType(Me.NumericUpDown4, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.DataGrid, System.ComponentModel.ISupportInitialize).EndInit()
		Me.TabPage3.ResumeLayout(False)
		Me.Panel2.ResumeLayout(False)
		Me.Panel1.ResumeLayout(False)
		Me.GroupBox1.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

#End Region

	'Create FormPrinting object
	Dim fp As FormPrinting.FormPrinting

	Private Sub ButtonPrintMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrintMe.Click

		CreateFormPrintingObject(Me)
		SetProperties()

		' Print!
		fp.Print()
		Me.ButtonTrace.Enabled = True

	End Sub

	Private Sub ButtonTifMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTif.Click

		CreateFormPrintingObject(Me)
		SetProperties()

		' Print!
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		fp.PrintToTifFile("Form")
		Me.Cursor = System.Windows.Forms.Cursors.Default
		MsgBox("Image has been saved in file Form.tif (Application folder)")
		Me.ButtonTrace.Enabled = True

	End Sub

	Private Sub ButtonPrintTab_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrintTab.Click

		CreateFormPrintingObject(Me.TabControl1.SelectedTab)
		SetProperties()

		' Print!
		fp.Print()
		Me.ButtonTrace.Enabled = True

	End Sub

	Private Sub CreateFormPrintingObject(ByVal c As System.Windows.Forms.Control)
		fp = New FormPrinting.FormPrinting(c)
		'FlexGrid (Need a reference to C1.FlexGrid) 
		'Dim fgp As FlexGridPrinting.FlexGridPrinting
		'fp.AddDelegateToPrintControl("FlexGrid", AddressOf fgp.PrintIt)
	End Sub

	Private Sub SetProperties()

		' Set printing options
		fp.TextBoxBoxed = Me.CheckBoxTextBoxBoxed.Checked
		fp.TabControlBoxed = Me.CheckBoxTabControlBoxed.Checked
		fp.LabelInBold = Me.CheckBoxLabelInBold.Checked
		fp.PrintPreview = Me.CheckBoxPrintPreview.Checked
		fp.DisabledControlsInGray = Me.CheckBoxDisabledControlsInGray.Checked
		fp.PageNumbering = Me.CheckBoxPageNumbering.Checked

		fp.Orientation = FormPrinting.FormPrinting.OrientationENum.Automatic
		If Me.RadioButtonPortrait.Checked Then
			fp.Orientation = FormPrinting.FormPrinting.OrientationENum.Portrait
		ElseIf Me.RadioButtonLandscape.Checked Then
			fp.Orientation = FormPrinting.FormPrinting.OrientationENum.Lanscape
		End If
		If Me.CheckBoxMyOwn.Checked Then
			fp.DelegatePrintingReportTitle = AddressOf MrOwnPrintReportTitle
		Else
			fp.DelegatePrintingReportTitle = Nothing
		End If
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTrace.Click
		MsgBox(fp.GetTrace())
	End Sub

	Private Sub DemoForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		LoadListBox1()
		LoadListBox2()
		LoadListBox3()
		LoadDataGrid()
		'LoadFlexGrid() 'FlexGrid (Need a reference to C1.FlexGrid) 
	End Sub

	Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
		LoadListBox1()
	End Sub

	Private Sub NumericUpDown1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.Leave
		LoadListBox1()
	End Sub

	Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged
		LoadListBox2()
	End Sub

	Private Sub NumericUpDown2_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.Leave
		LoadListBox2()
	End Sub

	Private Sub NumericUpDown3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown3.ValueChanged
		LoadListBox3()
	End Sub

	Private Sub NumericUpDown3_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown3.Leave
		LoadListBox3()
	End Sub

	Private Sub NumericUpDown4_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown4.ValueChanged
		LoadDataGrid()
	End Sub

	Private Sub NumericUpDown4_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown4.Leave
		LoadDataGrid()
	End Sub

	Private Sub LoadListBox1()
		Dim dt As New DataTable
		Dim dc As New DataColumn
		dc.ColumnName = "Col"
		dc.Caption = dc.ColumnName
		dt.Columns.Add(dc)
		For i As Integer = 1 To Me.NumericUpDown1.Value
			Dim values() As Object = {"Item #" & i}
			dt.Rows.Add(values)
		Next
		ListBox1.DataSource = dt
		ListBox1.DisplayMember = "Col"
	End Sub

	Private Sub LoadListBox2()
		Dim dt As New DataTable
		Dim dc As New DataColumn
		dc.ColumnName = "Col"
		dc.Caption = dc.ColumnName
		dt.Columns.Add(dc)
		For i As Integer = 1 To Me.NumericUpDown2.Value
			Dim values() As Object = {"Item #" & i}
			dt.Rows.Add(values)
		Next
		ListBox2.DataSource = dt
		ListBox2.DisplayMember = "Col"
	End Sub

	Private Sub LoadListBox3()
		Dim dt As New DataTable
		Dim dc As New DataColumn
		dc.ColumnName = "Col"
		dc.Caption = dc.ColumnName
		dt.Columns.Add(dc)
		For i As Integer = 1 To Me.NumericUpDown3.Value
			Dim values() As Object = {"Item #" & i}
			dt.Rows.Add(values)
		Next
		ListBox3.DataSource = dt
		ListBox3.DisplayMember = "Col"
	End Sub

	Private Sub LoadDataGrid()
		'Create a data table
		Dim dt As New DataTable
		For i As Integer = 1 To 5
			Dim dc As New DataColumn
			dc.ColumnName = "Col-" & i
			dc.Caption = dc.ColumnName
			dc.DefaultValue = i * i
			dt.Columns.Add(dc)
		Next
		For i As Integer = 1 To Me.NumericUpDown4.Value
			Dim values() As Object = {"Item #" & i, i * 3, 1000 - (i * i)}
			dt.Rows.Add(values)
		Next

		Me.DataGrid.DataSource = dt
	End Sub

	'FlexGrid (Need a reference to C1.FlexGrid)
	'Private Sub LoadFlexGrid()
	'    'Create a data table
	'    Dim dt As New DataTable
	'    For i As Integer = 1 To 5
	'        Dim dc As New DataColumn
	'        dc.ColumnName = "Col-" & i
	'        dc.Caption = dc.ColumnName
	'        dc.DefaultValue = i * i
	'        dt.Columns.Add(dc)
	'    Next
	'    For i As Integer = 0 To 68
	'        Dim values() As Object = {"Item #" & i, i * 3, 1000 - (i * i)}
	'        dt.Rows.Add(values)
	'    Next

	'    Fill(Flexgrid)
	'    C1FlexGrid1.DataSource = dt
	'    C1FlexGrid1.Cols(0).Visible = False
	'End Sub

	' Define my own title printer
	Private Sub MrOwnPrintReportTitle(ByVal c As System.Windows.Forms.Control, _
	ByVal typePrint As FormPrinting.FormPrinting.ParentControlPrinting, _
	ByVal mp As FormPrinting.FormPrinting.MultiPageManagement, _
	ByVal x As Single, ByVal y As Single, _
	ByRef extendedHeight As Single, ByRef ScanForChildControls As Boolean)

		ScanForChildControls = False
		Dim printFont As Font = New Font(c.Font.Name, CSng(c.Font.Size * 2.1), FontStyle.Bold)
		Dim fontHeight As Single = mp.FontHeight(printFont)
		Dim Pen As Pen = New Pen(Color.Black, 2)
		extendedHeight = fontHeight   3   Pen.Width   1

		mp.BeginPrintUnit(y, extendedHeight)
		Dim sf As StringFormat = New StringFormat
		sf.Alignment = StringAlignment.Center
		mp.DrawString(c.Text, printFont, Brushes.Gold, x, y, c.Width, fontHeight, sf)
		y  = fontHeight   3
		mp.DrawLines(Pen, x, y, x   c.Size.Width, y)
		y  = 3
		mp.DrawLines(Pen, x, y, x   c.Size.Width, y)
		y  = 1
		mp.DrawLines(Pen, x, y, x   c.Size.Width, y)
		mp.EndPrintUnit()
	End Sub
End Class

标签: 打印 报表 表单

实例下载地址

winform 以报表方式打印表单

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警