PrinterSettings.InstalledPrinters Property
Gets the names of all printers installed on the computer.
Namespace: System.Drawing.Printing
Assembly: System.Drawing (in System.Drawing.dll)
Property Value
Type: System.Drawing.Printing.PrinterSettings.StringCollectionA PrinterSettings.StringCollection that represents the names of all printers installed on the computer.
| Exception | Condition |
|---|---|
| Win32Exception | The available printers could not be enumerated. |
The following code example populates the comboInstalledPrinters combo box with the installed printers and also sets the printer to print, using the PrinterName property, when the selection changes. The PopulateInstalledPrintersCombo routine is called when the form is being initialized. The example requires that a PrintDocument variable named printDoc exists and that the specific combo box exists.
private void PopulateInstalledPrintersCombo() { // Add list of installed printers found to the combo box. // The pkInstalledPrinters string will be used to provide the display string. String pkInstalledPrinters; for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++){ pkInstalledPrinters = PrinterSettings.InstalledPrinters[i]; comboInstalledPrinters.Items.Add(pkInstalledPrinters); } } private void comboInstalledPrinters_SelectionChanged(object sender, System.EventArgs e) { // Set the printer to a printer in the combo box when the selection changes. if (comboInstalledPrinters.SelectedIndex != -1) { // The combo box's Text property returns the selected item's text, which is the printer name. printDoc.PrinterSettings.PrinterName= comboInstalledPrinters.Text; } }
- PrintingPermission
for printing and access to all printers on the network. Associated enumeration: PrintingPermissionLevel.AllPrinting
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.