PrinterSettings.IsDefaultPrinter Property


Gets a value indicating whether the PrinterName property designates the default printer, except when the user explicitly sets PrinterName.

Namespace:   System.Drawing.Printing
Assembly:  System.Drawing (in System.Drawing.dll)

public bool IsDefaultPrinter { get; }

Property Value

Type: System.Boolean

true if PrinterName designates the default printer; otherwise, false.

IsDefaultPrinter always returns false when you explicitly set the PrinterName property to a string value other than null.

The following example demonstrates how to use the IsDefaultPrinter property. To run this example, paste the following code into a form and call PopulateInstalledPrintersCombo from the form's constructor or Load event-handling method.

private ComboBox comboInstalledPrinters = new ComboBox();
private PrintDocument printDoc = new PrintDocument();

private void PopulateInstalledPrintersCombo()
    comboInstalledPrinters.Dock = DockStyle.Top;

    // Add list of installed printers found to the combo box.
    // The pkInstalledPrinters string will be used to provide the display string.
    int i;
    string pkInstalledPrinters;

    for (i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
        pkInstalledPrinters = PrinterSettings.InstalledPrinters[i];
        if (printDoc.PrinterSettings.IsDefaultPrinter)
            comboInstalledPrinters.Text = printDoc.PrinterSettings.PrinterName;

.NET Framework
Available since 1.1
Return to top