PrintPageEventArgs クラス
アセンブリ: System.Drawing (system.drawing.dll 内)


MarginBounds プロパティは、ページ余白どうしの間の部分を表す四角形領域を取得します。PageBounds プロパティは、ページの全領域を表す四角形領域を取得します。Graphics プロパティは、描画に使用するグラフィックス オブジェクトを定義します。PageSettings プロパティは、現在のページのプリンタ設定を取得します。その他のプロパティは、印刷ジョブをキャンセルするかどうか、または印刷ジョブに追加のページがあるかどうかを示します。

次のコード例は、Form 上に Button が作成されていることを前提にしています。例中の printButton_Click メソッドは、PrintDocument クラスのインスタンスを作成し、pd_PrintPage メソッドを呼び出し、pd_PrintPage メソッドで指定されている .bmp ファイルを出力します。この例を実行するには、印刷するビットマップにパスを変更します。
この例では、System.ComponentModel、System.Collections、System.Drawing、System.Drawing.Printing、System.Resources、System.Windows.Forms の各名前空間を使用します。
' Specifies what happens when the user clicks the Button. Private Sub printButton_Click(sender As Object, e As EventArgs) Try ' Assumes the default printer. Dim pd As New PrintDocument() AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage pd.Print() Catch ex As Exception MessageBox.Show("An error occurred while printing", _ ex.ToString()) End Try End Sub ' Specifies what happens when the PrintPage event is raised. Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs) ' Draw a picture. ev.Graphics.DrawImage(Image.FromFile("C:\My Folder\MyFile.bmp"), _ ev.Graphics.VisibleClipBounds) ' Indicate that this is the last page to print. ev.HasMorePages = False End Sub
// Specifies what happens when the user clicks the Button. private void printButton_Click(object sender, EventArgs e) { try { // Assumes the default printer. PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pd.Print(); } catch(Exception ex) { MessageBox.Show("An error occurred while printing", ex.ToString()); } } // Specifies what happens when the PrintPage event is raised. private void pd_PrintPage(object sender, PrintPageEventArgs ev) { // Draw a picture. ev.Graphics.DrawImage(Image.FromFile("C:\\My Folder\\MyFile.bmp"), ev.Graphics.VisibleClipBounds); // Indicate that this is the last page to print. ev.HasMorePages = false; }
private: // Specifies what happens when the user clicks the Button. void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ ) { try { // Assumes the default printer. PrintDocument^ pd = gcnew PrintDocument; pd->PrintPage += gcnew PrintPageEventHandler( this, &Form1::pd_PrintPage ); pd->Print(); } catch ( Exception^ ex ) { MessageBox::Show( "An error occurred while printing", ex->ToString() ); } } // Specifies what happens when the PrintPage event is raised. void pd_PrintPage( Object^ /*sender*/, PrintPageEventArgs^ ev ) { // Draw a picture. ev->Graphics->DrawImage( Image::FromFile( "C:\\My Folder\\MyFile.bmp" ), ev->Graphics->VisibleClipBounds ); // Indicate that this is the last page to print. ev->HasMorePages = false; }
// Specifies what happens when the user clicks the Button. private void printButton_Click(Object sender, EventArgs e) { try { // Assumes the default printer. PrintDocument pd = new PrintDocument(); pd.add_PrintPage(new PrintPageEventHandler(this.pd_PrintPage)); pd.Print(); } catch (System.Exception ex) { MessageBox.Show("An error occurred while printing", ex.ToString()); } } //printButton_Click // Specifies what happens when the PrintPage event is raised. private void pd_PrintPage(Object sender, PrintPageEventArgs ev) { // Draw a picture. ev.get_Graphics().DrawImage(Image.FromFile ("C:\\My Folder\\MyFile.bmp"), ev.get_Graphics().get_VisibleClipBounds()); // Indicate that this is the last page to print. ev.set_HasMorePages(false); } //pd_PrintPage

System.EventArgs
System.Drawing.Printing.PrintPageEventArgs


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


PrintPageEventArgs コンストラクタ
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Sub New ( _ graphics As Graphics, _ marginBounds As Rectangle, _ pageBounds As Rectangle, _ pageSettings As PageSettings _ )
Dim graphics As Graphics Dim marginBounds As Rectangle Dim pageBounds As Rectangle Dim pageSettings As PageSettings Dim instance As New PrintPageEventArgs(graphics, marginBounds, pageBounds, pageSettings)
public PrintPageEventArgs ( Graphics graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings pageSettings )
public: PrintPageEventArgs ( Graphics^ graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings^ pageSettings )
public PrintPageEventArgs ( Graphics graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings pageSettings )
public function PrintPageEventArgs ( graphics : Graphics, marginBounds : Rectangle, pageBounds : Rectangle, pageSettings : PageSettings )

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


PrintPageEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | Cancel | 印刷ジョブをキャンセルするかどうかを示す値を取得または設定します。 |
![]() | Graphics | ページの描画に使用される Graphics を取得します。 |
![]() | HasMorePages | 追加のページを印刷するかどうかを示す値を取得または設定します。 |
![]() | MarginBounds | ページ余白の内側の部分を表す四角形領域を取得します。 |
![]() | PageBounds | ページの全領域を表す四角形領域を取得します。 |
![]() | PageSettings | 現在のページのページ設定を取得します。 |

PrintPageEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

PrintPageEventArgs メンバ
PrintPageEventArgs データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Cancel | 印刷ジョブをキャンセルするかどうかを示す値を取得または設定します。 |
![]() | Graphics | ページの描画に使用される Graphics を取得します。 |
![]() | HasMorePages | 追加のページを印刷するかどうかを示す値を取得または設定します。 |
![]() | MarginBounds | ページ余白の内側の部分を表す四角形領域を取得します。 |
![]() | PageBounds | ページの全領域を表す四角形領域を取得します。 |
![]() | PageSettings | 現在のページのページ設定を取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- PrintPageEventArgsのページへのリンク