zoukankan      html  css  js  c++  java
  • c#打印机设置,取得打印机列表及相应打印机的所有纸张格式

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    using System.Drawing.Printing;
    
    
    
    namespace PrintDemo
    {
        /// <summary>
        /// 开发者:无名剑
        /// 网站:www.west163.net
        /// QQ:16349023
        /// Email:admin@xo68.com,admin@west163.net
        /// </summary>
        public partial class Form1 : XoExpress.SkinForm.SkinForm
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                PrintDocument prtdoc = new PrintDocument();
                string strdefaultprinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名
                foreach (string strprinter in PrinterSettings.InstalledPrinters)
                //在列表框中列出所有的打印机,
                {
                    listBoxEx1.Items.Add(strprinter);
                    if (strprinter == strdefaultprinter)//把默认打印机设为缺省值
                    {
                        listBoxEx1.SelectedIndex = listBoxEx1.Items.IndexOf(strprinter);
                    }
                } 
            }
    
    
    
            private void listBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
            {
                listBoxEx2.Items.Clear();
                PrintDocument prtdoc = new PrintDocument();
                prtdoc.PrinterSettings.PrinterName = listBoxEx1.Text;
                foreach (PaperSize ps in prtdoc.PrinterSettings.PaperSizes)
                {
                    listBoxEx2.Items.Add(ps.PaperName);
                }
            }
    
            private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                System.Diagnostics.Process.Start("IEXPLORE.EXE","http://www.west163.net");
            }
    
            private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://blog.csdn.net/nnsword");
            }
        }
    }
  • 相关阅读:
    扩欧(exgcd讲解)
    Django组件之forms
    Django组件之用户认证
    Django之中间件
    Django之cookie与session
    Django组件之分页器
    Django之Ajax
    Django之模型层2
    Django之模型层
    Django之模板层
  • 原文地址:https://www.cnblogs.com/zeroone/p/3306170.html
Copyright © 2011-2022 走看看