QueryPageSettingsEventArgs Klasa

Definicja

Udostępnia dane dla zdarzenia QueryPageSettings.

C#
public class QueryPageSettingsEventArgs : System.Drawing.Printing.PrintEventArgs
Dziedziczenie
QueryPageSettingsEventArgs

Przykłady

Poniższy przykład kodu drukuje dokument z pierwszą stroną w kolorze, jeśli drukarka go obsługuje. W przykładzie założono, że PrintDocument została utworzona zmienna o nazwie printDoc , a PrintPage zdarzenia i QueryPageSettings są obsługiwane.

System.Drawing W tym przykładzie użyj przestrzeni nazw i System.Drawing.Printing .

C#

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;
        }
    }    
}

Uwagi

Można wydrukować każdą stronę dokumentu przy użyciu różnych ustawień strony. Ustawienia strony można ustawić, modyfikując poszczególne właściwości PageSettings właściwości lub ustawiając właściwość na PageSettingswartość . Zadanie drukowania można również anulować, ustawiając Cancel właściwość na true.

Konstruktory

Właściwości

Cancel

Pobiera lub ustawia wartość wskazującą, czy zdarzenie powinno zostać anulowane.

(Odziedziczone po CancelEventArgs)
PageSettings

Pobiera lub ustawia ustawienia strony, które mają być drukowane.

PrintAction

Zwraca wartość PrintToFile we wszystkich przypadkach.

(Odziedziczone po PrintEventArgs)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Produkt Wersje
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Zobacz też