PrintDialog 클래스

정의

사용자가 Windows Forms 애플리케이션에서 인쇄할 때 프린터와 인쇄할 문서 구역을 선택할 수 있도록 합니다.

public ref class PrintDialog sealed : System::Windows::Forms::CommonDialog
public sealed class PrintDialog : System.Windows.Forms.CommonDialog
type PrintDialog = class
    inherit CommonDialog
Public NotInheritable Class PrintDialog
Inherits CommonDialog
상속

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다.는 PrintDialog 설정 하는 컨트롤 , ShowHelpAllowSomePages, 및 Document 속성입니다. 이 예제를 실행하려면 라는 컨트롤과 라는 PrintDialog1Button1단추가 포함된 PrintDialog 양식에 다음 코드를 붙여넣습니다. 이 예제에서는 단추의 Click 이벤트와 PrintPage 의 이벤트가 docToPrint 이 예제에 정의된 이벤트 처리 메서드에 연결되어야 합니다.

// Declare the PrintDocument object.
System::Drawing::Printing::PrintDocument^ docToPrint;

// This method will set properties on the PrintDialog object and
// then display the dialog.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   // Allow the user to choose the page range he or she would
   // like to print.
   PrintDialog1->AllowSomePages = true;
   
   // Show the help button.
   PrintDialog1->ShowHelp = true;
   
   // Set the Document property to the PrintDocument for 
   // which the PrintPage Event has been handled. To display the
   // dialog, either this property or the PrinterSettings property 
   // must be set 
   PrintDialog1->Document = docToPrint;
   if ( docToPrint == nullptr )
         System::Windows::Forms::MessageBox::Show(  "null" );

   ;
   ;
   if ( PrintDialog1 == nullptr )
         System::Windows::Forms::MessageBox::Show(  "pnull" );

   ;
   ;
   System::Windows::Forms::DialogResult result = PrintDialog1->ShowDialog();
   System::Windows::Forms::MessageBox::Show( result.ToString() );
   ;
   ;
   
   // If the result is OK then print the document.
   if ( result == ::DialogResult::OK )
   {
      docToPrint->Print();
   }

}

// The PrintDialog will print the document
// by handling the document's PrintPage event.
void document_PrintPage( Object^ /*sender*/, System::Drawing::Printing::PrintPageEventArgs^ e )
{
   // Insert code to render the page here.
   // This code will be called when the control is drawn.
   // The following code will render a simple
   // message on the printed document.
   String^ text = "In document_PrintPage method.";
   System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Arial",35,System::Drawing::FontStyle::Regular );
   
   // Draw the content.
   e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 10, 10 );
}

// Declare the PrintDocument object.
private System.Drawing.Printing.PrintDocument docToPrint = 
    new System.Drawing.Printing.PrintDocument();

// This method will set properties on the PrintDialog object and
// then display the dialog.
private void Button1_Click(System.Object sender, 
    System.EventArgs e)
{

    // Allow the user to choose the page range he or she would
    // like to print.
    PrintDialog1.AllowSomePages = true;

    // Show the help button.
    PrintDialog1.ShowHelp = true;

    // Set the Document property to the PrintDocument for 
    // which the PrintPage Event has been handled. To display the
    // dialog, either this property or the PrinterSettings property 
    // must be set 
    PrintDialog1.Document = docToPrint;

    DialogResult result = PrintDialog1.ShowDialog();

    // If the result is OK then print the document.
    if (result==DialogResult.OK)
    {
        docToPrint.Print();
    }
}

// The PrintDialog will print the document
// by handling the document's PrintPage event.
private void document_PrintPage(object sender, 
    System.Drawing.Printing.PrintPageEventArgs e)
{

    // Insert code to render the page here.
    // This code will be called when the control is drawn.

    // The following code will render a simple
    // message on the printed document.
    string text = "In document_PrintPage method.";
    System.Drawing.Font printFont = new System.Drawing.Font
        ("Arial", 35, System.Drawing.FontStyle.Regular);

    // Draw the content.
    e.Graphics.DrawString(text, printFont, 
        System.Drawing.Brushes.Black, 10, 10);
}

' Declare the PrintDocument object.
Private WithEvents docToPrint As New Printing.PrintDocument

' This method will set properties on the PrintDialog object and
' then display the dialog.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    ' Allow the user to choose the page range he or she would
    ' like to print.
    PrintDialog1.AllowSomePages = True

    ' Show the help button.
    PrintDialog1.ShowHelp = True

    ' Set the Document property to the PrintDocument for 
    ' which the PrintPage Event has been handled. To display the
    ' dialog, either this property or the PrinterSettings property 
    ' must be set 
    PrintDialog1.Document = docToPrint

    Dim result As DialogResult = PrintDialog1.ShowDialog()

    ' If the result is OK then print the document.
    If (result = DialogResult.OK) Then
        docToPrint.Print()
    End If

End Sub

' The PrintDialog will print the document
' by handling the document's PrintPage event.
Private Sub document_PrintPage(ByVal sender As Object, _
   ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
       Handles docToPrint.PrintPage

    ' Insert code to render the page here.
    ' This code will be called when the control is drawn.

    ' The following code will render a simple
    ' message on the printed document.
    Dim text As String = "In document_PrintPage method."
    Dim printFont As New System.Drawing.Font _
        ("Arial", 35, System.Drawing.FontStyle.Regular)

    ' Draw the content.
    e.Graphics.DrawString(text, printFont, _
        System.Drawing.Brushes.Black, 10, 10)
End Sub

설명

PrintDialoginstance 만들면 읽기/쓰기 속성이 초기 값으로 설정됩니다. 이러한 값의 목록을 보려면 참조는 PrintDialog 생성자입니다. 를 사용하여 사용자가 PrintDialog수정한 프린터 설정을 얻으려면 속성을 사용합니다 PrinterSettings .

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

생성자

PrintDialog()

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

속성

AllowCurrentPage

현재 페이지 옵션 단추가 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

AllowPrintToFile

파일로 인쇄 확인란을 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

AllowSelection

선택 영역 옵션 단추를 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

AllowSomePages

페이지 옵션 단추를 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

CanRaiseEvents

구성 요소가 이벤트를 발생시킬 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Container

IContainer을 포함하는 Component를 가져옵니다.

(다음에서 상속됨 Component)
DesignMode

Component가 현재 디자인 모드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Document

PrintDocument를 가져오는 데 사용하는 PrinterSettings를 나타내는 값을 가져오거나 설정합니다.

Events

Component에 연결된 이벤트 처리기의 목록을 가져옵니다.

(다음에서 상속됨 Component)
PrinterSettings

대화 상자에서 수정하는 프린터 설정을 가져오거나 설정합니다.

PrintToFile

파일로 인쇄 확인란이 선택되어 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

ShowHelp

도움말 단추가 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

ShowNetwork

네트워크 단추가 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

Site

ComponentISite를 가져오거나 설정합니다.

(다음에서 상속됨 Component)
Tag

컨트롤에 대한 데이터가 들어 있는 개체를 가져오거나 설정합니다.

(다음에서 상속됨 CommonDialog)
UseEXDialog

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 이상을 실행하는 시스템의 경우 대화 상자를 Windows XP 스타일로 표시할지 여부를 나타내는 값을 가져오거나 설정합니다.

메서드

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

Component에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

Component에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

(다음에서 상속됨 Component)
Equals(Object)

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

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

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

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetService(Type)

Component 또는 해당 Container에서 제공하는 서비스를 나타내는 개체를 반환합니다.

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

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

(다음에서 상속됨 Object)
HookProc(IntPtr, Int32, IntPtr, IntPtr)

일반 대화 상자에 특정 기능을 추가하도록 재정의된 일반 대화 상자의 후크 프로시저를 정의합니다.

(다음에서 상속됨 CommonDialog)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

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

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

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

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
OnHelpRequest(EventArgs)

HelpRequest 이벤트를 발생시킵니다.

(다음에서 상속됨 CommonDialog)
OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr)

일반 대화 상자에 특정 기능을 추가하도록 재정의된 소유자 창 프로시저를 정의합니다.

(다음에서 상속됨 CommonDialog)
Reset()

모든 옵션, 마지막으로 선택한 프린터 및 페이지 설정을 기본값으로 다시 설정합니다.

RunDialog(IntPtr)

파생 클래스에서 재정의된 경우 일반 대화 상자를 지정합니다.

(다음에서 상속됨 CommonDialog)
ShowDialog()

기본 소유자로 일반 대화 상자를 실행합니다.

(다음에서 상속됨 CommonDialog)
ShowDialog(IWin32Window)

지정된 소유자로 일반 대화 상자를 실행합니다.

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

Component의 이름이 포함된 String을 반환합니다(있는 경우). 이 메서드는 재정의할 수 없습니다.

(다음에서 상속됨 Component)

이벤트

Disposed

Dispose() 메서드를 호출하여 구성 요소를 삭제할 때 발생합니다.

(다음에서 상속됨 Component)
HelpRequest

일반 대화 상자의 도움말 단추를 클릭하면 발생합니다.

(다음에서 상속됨 CommonDialog)

적용 대상

추가 정보