首  页
站长信箱
868搜索
网站登录
免费计数器
免费留言本
IP来源查询
网站技术教程
网站流量统计
文章探索:   分类:    关键字:  
    什么?你还在找兼职?上兼客吧,现在兼客吧平台太火了,知名度和诚信度也很高,注册就送0.5元现金,满3元就能提现,马上到账了!最低3元就能提现,大家可以注册下试试!注册地址:http://www.jiankeba.com/computeryc1688
  + 栏目导航
  + 相关文章
VB.Net打印设置打印预览和预览..
VB.Net抓取网页乱码的解决方法
如何用VB.Net创建一个三层的数..
使用TreeView控件
在VB.NET中使用动态属性
用VB.NET轻松制作特效窗体

技术教程 -> VB.Net教程 ->  
VB.Net打印设置打印预览和预览控制器的实例
来源:乐博网lob.cn   人气:3085   录入时间:2010/1/29


    提示:调试环境为 vs2005 + windows2003 / windows2008 / xp / vista
   
   代码如下:
   
   Public Class PrintForm
    Dim pageset As Printing.PageSettings = New Printing.PageSettings()
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    PageSetupDialog1.Document = PrintDocument1 ''设置Document属性=文档对象或者与PageSettings类关联就可以使用该控件
    PageSetupDialog1.AllowMargins = True
    PageSetupDialog1.PageSettings = PrintDocument1.DefaultPageSettings
    Dim re As DialogResult = PageSetupDialog1.ShowDialog()
    If re = Windows.Forms.DialogResult.OK Then
    pageset = PageSetupDialog1.PageSettings
    End If
    End Sub
    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
    Dim mypen As Pen = New Pen(Color.Blue, 2)
    PrintDocument1.DefaultPageSettings = pageset
    e.Graphics.DrawString(RichTextBox1.Text, New Font("黑体", 15), mypen.Brush, 10, 10)
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    PrintDialog1.Document = PrintDocument1
    PrintDialog1.PrinterSettings.Copies = 5 ''打印的份数
    PrintDialog1.PrinterSettings.FromPage = 1 ''第一页的页码
    PrintDialog1.PrinterSettings.ToPage = 5 ''最后一页页码
    Dim re As DialogResult = PrintDialog1.ShowDialog()
    If re = Windows.Forms.DialogResult.OK Then
    AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage
    PrintDocument1.Print()
    End If
    End Sub '更多.net源码和教程,来自[乐 博 网 www.lob.cn]
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    PrintPreviewDialog1.Document = PrintDocument1
    AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage
    PrintPreviewDialog1.PrintPreviewControl.Zoom = 1.0
    PrintPreviewDialog1.WindowState = FormWindowState.Normal
    PrintPreviewDialog1.ShowDialog()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim PrintPreviewControl1 As PrintPreviewControl = New PrintPreviewControl
    PrintPreviewControl1.Name = "PrintPreviewControl1"
    PrintPreviewControl1.Dock = DockStyle.Fill
    PrintPreviewControl1.Document = PrintDocument1
    PrintPreviewControl1.UseAntiAlias = True
    AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage
    Form1.Controls.Add(PrintPreviewControl1)
    PrintPreviewControl1.Show()
    Form1.Show()
    End Sub
   
   End Class
   



| 网站转让 | 站长信箱 | 网站登录 | 技术教程 | 免费计数器 | 免费留言本 | 868流量统计 | 好帮手网站营销 |
地址:广东省阳江市  联系电话:13725641179 杨先生
Copyright 2004-2019 868资源网- 版权所有    粤ICP备05007330号