PrintPageEventArgs 클래스

정의

PrintPage 이벤트에 대한 데이터를 제공합니다.

public ref class PrintPageEventArgs : EventArgs
public class PrintPageEventArgs : EventArgs
type PrintPageEventArgs = class
    inherit EventArgs
Public Class PrintPageEventArgs
Inherits EventArgs
상속
PrintPageEventArgs

예제

다음 코드 예제에서는 명명된 ButtonPrintDocument 라는 printButtonpd 에 만들어졌다고 가정합니다Form. 의 ClickButton 이벤트가 메서드와 printButton_Click 연결되어 있고 PrintPage 의 이벤트가 예제의 PrintDocument 메서드와 pd_PrintPage 연결되어 있는지 확인합니다. 예제의 메서드는 printButton_Click 이벤트를 발생시키는 Print 메서드를 PrintPage 호출하고 메서드에 pd_PrintPage 지정된 .bmp 파일을 출력합니다. 이 예제를 실행하려면 인쇄할 비트맵의 경로를 변경합니다.

이 예제에서는 System.Drawing, System.Drawing.PrintingSystem.Windows.Forms 네임스페이스를 사용합니다.

private:
   // Specifies what happens when the user clicks the Button.
   void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         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.
     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;
 }
' Specifies what happens when the user clicks the Button.
Private Sub printButton_Click(sender As Object, e As EventArgs) _
Handles printButton.Click
    Try
       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) _
Handles pd.PrintPage

    ' 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

설명

참고

.NET 6 이상 버전에서는 이 형식을 포함하는 System.Drawing.Common 패키지가 Windows 운영 체제에서만 지원됩니다. 플랫폼 간 앱에서 이 형식을 사용하면 컴파일 시간 경고 및 런타임 예외가 발생합니다. 자세한 내용은 Windows에서만 지원되는 System.Drawing.Common을 참조하세요.

속성은 MarginBounds 여백 사이의 페이지 부분을 나타내는 사각형 영역을 검색합니다. 속성은 PageBounds 페이지의 총 영역을 나타내는 사각형 영역을 검색합니다. 속성은 Graphics 그리기를 수행할 그래픽 개체를 정의합니다. 속성은 PageSettings 현재 페이지의 프린터 설정을 검색합니다. 나머지 속성은 인쇄 작업을 취소해야 하는지 또는 인쇄 작업에 더 많은 페이지가 있는지 여부를 나타냅니다.

Windows Forms를 사용 하 여 인쇄에 대 한 자세한 내용은 참조는 System.Drawing.Printing 네임 스페이스 개요. Windows Presentation Foundation 애플리케이션에서 인쇄 하려는 경우 참조는 System.Printing 네임 스페이스입니다.

생성자

PrintPageEventArgs(Graphics, Rectangle, Rectangle, PageSettings)

PrintPageEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

Cancel

인쇄 작업을 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

Graphics

페이지를 그리는 데 사용되는 Graphics를 가져옵니다.

HasMorePages

추가 페이지를 인쇄해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

MarginBounds

여백 내의 페이지 부분을 나타내는 사각형 영역을 가져옵니다.

PageBounds

페이지의 전체 영역을 나타내는 사각형 영역을 가져옵니다.

PageSettings

현재 페이지에 대한 페이지 설정을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보