Questa procedura VB.net serve per enumerare le stampanti installate nel sistema in uso.
Codice
Questo codice enumera le stampanti installate, riempie un ComboBox e ne preseleziona la linea relativa alla stampante predefinita.
Imports System.Drawing.Printing
Private Sub EnumeraStampanti()
' trova la stampante predefinita
Dim documento As New PrintDocument
Dim predefinita As String = documento.PrinterSettings.PrinterName
' enumera le stampanti installate nel sistema in uso
' e riempie un combo box
ComboBox1.Items.Clear()
For Each stampante As String In PrinterSettings.InstalledPrinters()
ComboBox1.Items.Add(stampante)
If stampante = predefinita Then
' preseleziona la stampante predefinita
ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(stampante)
End If
Next
End Sub
