QueryPageSettingsEventArgs 클래스

정의

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

public ref class QueryPageSettingsEventArgs : System::Drawing::Printing::PrintEventArgs
public class QueryPageSettingsEventArgs : System.Drawing.Printing.PrintEventArgs
type QueryPageSettingsEventArgs = class
    inherit PrintEventArgs
Public Class QueryPageSettingsEventArgs
Inherits PrintEventArgs
상속
QueryPageSettingsEventArgs

예제

다음 코드 예제에서는 프린터에서 지원하는 경우 첫 번째 페이지가 색인 문서를 인쇄합니다. 이 예제에서는 라는 printDoc 변수가 PrintDocument 생성되었으며 및 PrintPageQueryPageSettings 이벤트가 처리된다고 가정합니다.

이 예제에서는 System.DrawingSystem.Drawing.Printing 네임스페이스를 사용합니다.

private:
   void MyButtonPrint_OnClick( Object^ sender, System::EventArgs^ e )
   {
      // Set the printer name and ensure it is valid. If not, provide a message to the user.
      printDoc->PrinterSettings->PrinterName = "\\mynetworkprinter";
      if ( printDoc->PrinterSettings->IsValid )
      {
         // If the printer supports printing in color, then override the printer's default behavior.
         if ( printDoc->PrinterSettings->SupportsColor )
         {
            // Set the page default's to not print in color.
            printDoc->DefaultPageSettings->Color = false;
         }

         // Provide a friendly name, set the page number, and print the document.
         printDoc->DocumentName = "My Presentation";
         currentPageNumber = 1;
         printDoc->Print();
      }
      else
      {
         MessageBox::Show( "Printer is not valid" );
      }
   }

   void MyPrintQueryPageSettingsEvent( Object^ sender, QueryPageSettingsEventArgs^ e )
   {
      // Determines if the printer supports printing in color.
      if ( printDoc->PrinterSettings->SupportsColor )
      {
         // If the printer supports color printing, use color.
         if ( currentPageNumber == 1 )
         {
            e->PageSettings->Color = true;
         }
      }
   }

private void MyButtonPrint_OnClick(object sender, System.EventArgs e)
{
    
    // Set the printer name and ensure it is valid. If not, provide a message to the user.
    printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter";

    if (printDoc.PrinterSettings.IsValid) {
    
        // If the printer supports printing in color, then override the printer's default behavior.
        if (printDoc.PrinterSettings.SupportsColor) {

            // Set the page default's to not print in color.
            printDoc.DefaultPageSettings.Color = false;
        }

        // Provide a friendly name, set the page number, and print the document.
        printDoc.DocumentName = "My Presentation";
        currentPageNumber = 1;
        printDoc.Print();
    }
    else {
        MessageBox.Show("Printer is not valid");
    }
}

private void MyPrintQueryPageSettingsEvent(object sender, QueryPageSettingsEventArgs e)
{
    // Determines if the printer supports printing in color.
    if (printDoc.PrinterSettings.SupportsColor) {

        // If the printer supports color printing, use color.
        if (currentPageNumber == 1 ) {

            e.PageSettings.Color = true;
        }
    }    
}

Private Sub MyButtonPrint_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Set the printer name and ensure it is valid. If not, provide a message to the user.
    printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter"

    If printDoc.PrinterSettings.IsValid Then

        ' If the printer supports printing in color, then override the printer's default behavior.
        if printDoc.PrinterSettings.SupportsColor then

            ' Set the page default's to not print in color.
            printDoc.DefaultPageSettings.Color = False
        End If

        ' Provide a friendly name, set the page number, and print the document.
        printDoc.DocumentName = "My Presentation"
        currentPageNumber = 1
        printDoc.Print()
    Else
        MessageBox.Show("Printer is not valid")
    End If
End Sub

Private Sub MyPrintQueryPageSettingsEvent(ByVal sender As Object, ByVal e As QueryPageSettingsEventArgs)

    ' Determines if the printer supports printing in color.
    If printDoc.PrinterSettings.SupportsColor Then

        ' If the printer supports color printing, use color.
        If currentPageNumber = 1 Then

            e.PageSettings.Color = True
        End If

    End If
End Sub

설명

다른 페이지 설정을 사용하여 문서의 각 페이지를 인쇄할 수 있습니다. 속성의 PageSettings 개별 속성을 수정하거나 속성을 로 설정 PageSettings하여 페이지 설정을 지정합니다. 속성을 true로 설정 Cancel 하여 인쇄 작업을 취소할 수도 있습니다.

생성자

QueryPageSettingsEventArgs(PageSettings)

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

속성

Cancel

이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 CancelEventArgs)
PageSettings

인쇄할 페이지에 대한 페이지 설정을 가져오거나 설정합니다.

PrintAction

모든 경우에 PrintToFile 를 반환합니다.

(다음에서 상속됨 PrintEventArgs)

메서드

Equals(Object)

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상

추가 정보