• winform 打印预览


    code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsTest
    {
        public partial class Form8 : Form
        {
            public Form8()
            {
                InitializeComponent();
                this.printDocument1.OriginAtMargins = true;//启用页边距
                this.pageSetupDialog1.EnableMetric = true; //以毫米为单位
    
            }
    
            private void btnSetPrint_Click(object sender, EventArgs e)
            {//打印设置
                this.pageSetupDialog1.ShowDialog(); 
    
            }
    
            private void btnPrePrint_Click(object sender, EventArgs e)
            { //打印预览
                //指定要打印的文档
                //printPreviewDialog1.Document = printDocument1;
                this.printPreviewDialog1.ShowDialog(); 
    
            }
    
            private void btnPrint_Click(object sender, EventArgs e)
            {//打印
                if (this.printDialog1.ShowDialog() == DialogResult.OK)
                {
                    this.printDocument1.Print();
                }
            }
    
            private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                //打印内容 为 自定义文本内容 
                Font font = new Font("宋体", 12);
                Brush bru = Brushes.Blue;
                for (int i = 1; i <= 5; i++)
                {
                    e.Graphics.DrawString(lbMsg.Text, font, bru, 0, i * 20);
                }
            }
        }
    }
    
  • 相关阅读:
    Cannot load php5apache2_4.dll into server
    PHP合并数组
    为什么 echo 3 . print(2) . print(4) . 5 . 'c'的结果是45c2131
    PHP数据类型
    PHP变量
    SSH Key
    VMware Tools安装教程
    nginx: [emerg] getpwnam("nginx") failed
    JS 生成随机数
    JS 操作 cookie
  • 原文地址:https://www.cnblogs.com/suntanyong88/p/5844761.html
Copyright © 2020-2023  润新知