本文介绍了C#如何使用Windows 7打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 7中,当您选择一些图片并单击打印按钮时,会出现一个对话框,显示您选择的图片。



我想在这样的对话框中使用我的C#程序。

In windows 7 when you select some pictures and click print button, a dialog show you pictures that you selected.

I would like to use such a dialog in my C# program.

推荐答案

// Declare the dialog.
   internal PrintPreviewDialog PrintPreviewDialog1;

   // Declare a PrintDocument object named document.
   private System.Drawing.Printing.PrintDocument document =
       new System.Drawing.Printing.PrintDocument();

   // Initalize the dialog.
   private void InitializePrintPreviewDialog()
   {

       // Create a new PrintPreviewDialog using constructor.
       this.PrintPreviewDialog1 = new PrintPreviewDialog();

       //Set the size, location, and name.
       this.PrintPreviewDialog1.ClientSize =
           new System.Drawing.Size(400, 300);
       this.PrintPreviewDialog1.Location =
           new System.Drawing.Point(29, 29);
       this.PrintPreviewDialog1.Name = "PrintPreviewDialog1";

       // Associate the event-handling method with the
       // document's PrintPage event.
       this.document.PrintPage +=
           new System.Drawing.Printing.PrintPageEventHandler
           (document_PrintPage);

       // Set the minimum size the dialog can be resized to.
       this.PrintPreviewDialog1.MinimumSize =
           new System.Drawing.Size(375, 250);

       // Set the UseAntiAlias property to true, which will allow the
       // operating system to smooth fonts.
       this.PrintPreviewDialog1.UseAntiAlias = true;
   }


这篇关于C#如何使用Windows 7打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:49