zoukankan      html  css  js  c++  java
  • 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);
                }
            }
        }
    }
    
  • 相关阅读:
    ABP文档
    SqlServer英文单词全字匹配
    npm不是以管理身份运行遇到的问题
    concurrenthashmap jdk1.8
    HashSet源码分析 jdk1.6
    Iterator设计模式--jdk1.7
    代理模式
    高并发下的HashMap,ConcurrentHashMap
    HashMap源码分析jdk1.6
    Stack&Vector源码分析 jdk1.6
  • 原文地址:https://www.cnblogs.com/suntanyong88/p/5844761.html
Copyright © 2011-2022 走看看