PrintPageEventArgsとは? わかりやすく解説

PrintPageEventArgs クラス

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

名前空間: System.Drawing.Printing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Class PrintPageEventArgs
    Inherits EventArgs
Dim instance As PrintPageEventArgs
public class PrintPageEventArgs : EventArgs
public ref class PrintPageEventArgs : public
 EventArgs
public class PrintPageEventArgs extends EventArgs
public class PrintPageEventArgs extends
 EventArgs
解説解説
使用例使用例

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

この例では、System.ComponentModelSystem.CollectionsSystem.DrawingSystem.Drawing.PrintingSystem.ResourcesSystem.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.Object
   System.EventArgs
    System.Drawing.Printing.PrintPageEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PrintPageEventArgs メンバ
System.Drawing.Printing 名前空間
Graphics クラス
Rectangle 構造体
PrintEventArgs クラス

PrintPageEventArgs コンストラクタ

PrintPageEventArgs クラス新しインスタンス初期化します。

名前空間: System.Drawing.Printing
アセンブリ: 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
)

パラメータ

graphics

項目の描画使用される Graphics

marginBounds

余白余白の間の領域

pageBounds

用紙の全領域

pageSettings

ページPageSettings

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PrintPageEventArgs クラス
PrintPageEventArgs メンバ
System.Drawing.Printing 名前空間
Graphics クラス
Rectangle 構造体

PrintPageEventArgs プロパティ


PrintPageEventArgs メソッド


PrintPageEventArgs メンバ

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

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド PrintPageEventArgs PrintPageEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

PrintPageEventArgs クラス
System.Drawing.Printing 名前空間
Graphics クラス
Rectangle 構造体
PrintEventArgs クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「PrintPageEventArgs」の関連用語

PrintPageEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



PrintPageEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS