printDialog1就是来按照你的要求定义纸张的,
你省略了这个对话框怎么行?

解决方案 »

  1.   

    我也碰到过这种问题!!
    代码大致如下:
    pringdialog.Document = this.pDocument;
    if (printDialog1.ShowDialog() == DialogResult.OK)
     {
          this.pdocument.Print();
     }如果选的是默认打印机则没有问题;若选其他的打印机则无法取到自定义的纸张!
      

  2.   

    问题没有解决可能是几位所讲的原因吧,一个变通的办法。系统发一个回车事件这样也不用选打印机了,代码如下:
                System.Windows.Forms.SendKeys.Send("{ENTER}");
    if (printDialog1.ShowDialog() == DialogResult.OK)
    {
           printDocument1.Print();
    }
    回复 fanjun(红狼) : ThePrintDocument.DefaultPageSettings = this.storePageSetting;
    我把设置赋给了默认打印机,看能不能赋给说选的打印机,或者像我不给选择的机会
      

  3.   

    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument;
    System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();    //打印机设置
    printDialog.Document = printDocument;
    if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
    System.Windows.Forms.PageSetupDialog pageSetupDialog = new System.Windows.Forms.PageSetupDialog();    //页面设置
    pageSetupDialog.Document = printDocument;
    pageSetupDialog.ShowDialog();
    printDocument.Print();
    }