我想要的是怎么设置printDialog的Document属性  因为它都是空的 该怎么弄才能让它有内容啊

解决方案 »

  1.   

    怎么设置printDialog的Document属性  下拉菜单中总是空的
      

  2.   

    if (printDialog1.ShowDialog() == DialogResult.OK)
                    {
                        printDocument1.PrinterSettings = printDialog1.PrinterSettings;
                        printDocument1.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings;
                        printDocument1.DefaultPageSettings.Margins = new Margins(20, 20, 20, 20);
                        printDocument1.Print();
                    }
      

  3.   

    拖一个printDocument控件和一个printDialog控件到窗体上来,然后输入以下代码:
    this.printDialog1.Document = this.printDocument1;
      

  4.   

    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;
    using System.Drawing.Printing;namespace Test6
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            PrintDocument pd = new PrintDocument();
            private void Form1_Load(object sender, EventArgs e)
            {
                //label1.Text = DateTime.Now.ToString();
               // timer1.Start();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
              //  label1.Text = DateTime.Now.ToString();
            }        private void textBox1_TextChanged(object sender, EventArgs e)
            {        }        private void button2_Click(object sender, EventArgs e)
            {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                pd.PrintPage += new PrintPageEventHandler(pd1);
                ppd.Document = pd;
                ppd.ShowDialog();
            }        private void button1_Click(object sender, EventArgs e)
            {
                pd.DocumentName = "测试打印机";
                
                //pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                //if(pd.prin)
                pd.Print();
            }        void pd1(object sender, PrintPageEventArgs e)
            {
                e.Graphics.DrawString(textBox1.Text,new Font("avail",20),Brushes.Red,10,10,new StringFormat());
            }