PrintDocument.PrintController 属性

获取或设置指导打印进程的打印控制器。

**命名空间:**System.Drawing.Printing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Property PrintController As PrintController
用法
Dim instance As PrintDocument
Dim value As PrintController

value = instance.PrintController

instance.PrintController = value
public PrintController PrintController { get; set; }
public:
property PrintController^ PrintController {
    PrintController^ get ();
    void set (PrintController^ value);
}
/** @property */
public PrintController get_PrintController ()

/** @property */
public void set_PrintController (PrintController value)
public function get PrintController () : PrintController

public function set PrintController (value : PrintController)

属性值

指导打印进程的 PrintController。默认情况下为 PrintControllerWithStatusDialog 类的一个新实例。

备注

打印控制器用几种方法来指导打印进程。例如,要打印某一文档,需要将它转换为 Graphics 对象。PrintController 指定在何处绘制图形,是在图像中绘制以进行打印预览,还是在打印机上绘制以实际打印该文档。打印控制器还可以指定是立即打印文档,还是等待一段指定的时间间隔。

示例

下面的代码示例要求已创建一个 PrintDocument 类的实例,它被命名为 myPrintDocument。此示例创建 PrintController 类的一个新实例,将该实例分配给 myPrintDocumentPrintController 属性,然后打印该文档。

在此示例中使用 System.Drawing.PrintingSystem.Windows.Forms 命名空间。

Public Sub myPrint()
    If useMyPrintController = True Then
        myPrintDocument.PrintController = New myControllerImplementation()
        If wantsStatusDialog = True Then
            myPrintDocument.PrintController = _
               New PrintControllerWithStatusDialog( _
               myPrintDocument.PrintController)
        End If
    End If
    myPrintDocument.Print()
End Sub
public void myPrint()
{
   if (useMyPrintController == true)
   {
      myPrintDocument.PrintController = 
         new myControllerImplementation();     
      if (wantsStatusDialog == true)
      {
         myPrintDocument.PrintController = 
            new PrintControllerWithStatusDialog
            (myPrintDocument.PrintController);
      }
   }
   myPrintDocument.Print();
}
public:
   void myPrint()
   {
      if ( useMyPrintController == true )
      {
         myPrintDocument->PrintController =
            gcnew myControllerImplementation;
         if ( wantsStatusDialog == true )
         {
            myPrintDocument->PrintController =
               gcnew PrintControllerWithStatusDialog(
                  myPrintDocument->PrintController );
         }
      }
      myPrintDocument->Print();
   }
public void MyPrint()
{
    if (useMyPrintController == true) {
        myPrintDocument.set_PrintController
            (new MyControllerImplementation());
        if (wantsStatusDialog == true) {
            myPrintDocument.set_PrintController
                (new PrintControllerWithStatusDialog
                (myPrintDocument.get_PrintController()));
        }
    }
    myPrintDocument.Print();
} //MyPrint

.NET Framework 安全性

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PrintDocument 类
PrintDocument 成员
System.Drawing.Printing 命名空间
PrintDocument.DefaultPageSettings 属性
PrintDocument.DocumentName 属性
PreviewPrintController 类
PrintController 类
PrintControllerWithStatusDialog
PrinterSettings
StandardPrintController