Retrieving the default Printer.

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)
   m_printerNameCombo.Items.Add(printerName);
PrinterSettings defaultPrinterSettings = new PrinterSettings();
m_printerNameCombo.SelectedItem = defaultPrinterSettings.PrinterName;

Leave a Reply

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