Windows フォームの PrintDialog を利用する方法

  Windows フォームの PrintDialog を利用するには、ベースとなる FormPageSetupDialog を組込んで使用します。
【使い方】

 PrintDialog の Document プロパティに PrintDocument を設定して、ダイアログを表示させる。
// MyPrintDocument は、印刷の対象となる PrintDocument

// PrintDialog のインスタンスを生成 (通常フォーム デザイナが生成)
private System.Windows.Forms.PrintDialog prtDlg;
this.prtDlg = new System.Windows.Forms.PrintDialog();


// PrintDialog に PrintDocument を設定
prtDlg.Document = MyPrintDocument;


// PrintDialog の起動&戻り値確認
if ( prtDlg.ShowDialog() == DialogResult.OK )
{
    if ( MyPrintDocument != null )
        MyPrintDocument.Print();
}
【注意】
戻る