Tony Wall’s Blog

Remember quality? A bit more time upfront saves a ton of trouble later ;-)

Retrieving the default Printer.

Microsoft .NET WinForms
Seems a bit obvious when you know how, but when you want the default printer name or the whole settings, you simply construct a PrinterSettings class and read the PrinterName property or others as desired. This is not obvious when finding your way through the MSDN documentation, in which you are shown how to fill a ComboBox with a list of InstalledPrinters, but not the next obvious step which is to pre-select the default one. Here is the whole code:-

foreach (string printerName in PrinterSettings.InstalledPrinters)
PrinterSettings defaultPrinterSettings = new PrinterSettings();
m_printerNameCombo.SelectedItem = defaultPrinterSettings.PrinterName;

Leave a Reply

Your email address will not be published. Required fields are marked *