次の方法で共有


PrintPageEventArgs クラス

PrintPage イベントのデータを提供します。

この型のすべてのメンバの一覧については、PrintPageEventArgs メンバ を参照してください。

System.Object
   System.EventArgs
      System.Drawing.Printing.PrintPageEventArgs

Public Class PrintPageEventArgs
   Inherits EventArgs
[C#]
public class PrintPageEventArgs : EventArgs
[C++]
public __gc class PrintPageEventArgs : public EventArgs
[JScript]
public class PrintPageEventArgs extends EventArgs

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

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

印刷の詳細については、 System.Drawing.Printing 名前空間のトピックを参照してください。

使用例

[Visual Basic, C#, C++] この例では、 System.ComponentModelSystem.CollectionsSystem.DrawingSystem.Drawing.PrintingSystem.ResourcesSystem.Windows.Forms の各名前空間を使用します。

[Visual Basic, C#, C++] 次の例は、 Form 上に Button が作成されていることを前提にしています。例中の printButton_Click メソッドは、 PrintDocument のインスタンスを作成し、 pd_PrintPage メソッドを呼び出し、 pd_PrintPage メソッドで指定されている .bmp ファイルを出力します。この例を実行するには、印刷するビットマップにパスを変更します。

 
' 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


[C#] 
// 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;
 }
 

[C++] 
// 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, &Form1::pd_PrintPage);
     pd->Print();
   }  
   catch(Exception* ex) 
   {
     MessageBox::Show(S"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(S"C:\\My Folder\\MyFile.bmp"), ev->Graphics->VisibleClipBounds);
      
   // Indicate that this is the last page to print.
   ev->HasMorePages = false;
 }
 

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Drawing.Printing

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Drawing (System.Drawing.dll 内)

参照

PrintPageEventArgs メンバ | System.Drawing.Printing 名前空間 | Graphics | Rectangle | PrintEventArgs