Public Class Form1
Private geladen As Boolean
Private PrintDoc As New Printing.PrintDocument
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Standarddrucker As String
With ComboBox1
For Each s In Printing.PrinterSettings.InstalledPrinters
.Items.Add(s)
If s = PrintDoc.PrinterSettings.PrinterName Then
Standarddrucker = s
End If
Next s
If .Items.Count > 0 Then
'// Standarddrucker markieren
' aber nur wenn vorher kein Drucker von dir selektiert wurde
Dim i As Integer = _
Me.ComboBox1.FindStringExact(clsSettings.GetSetting("ComboBox", "dein_Drucker", "DeineConfigDatei.xml"))
If i = -1 Then
'// Standarddrucker setzen
i = Me.ComboBox1.FindStringExact(Standarddrucker)
Else
'// eigener Drucker wurde gefunden
End If
Me.ComboBox1.SelectedIndex = i
Else
MessageBox.Show("Es ist kein Drucker installiert!", "Abbruch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.Close()
End If
End With
PrintDoc.DocumentName = "Druckdokument"
AddHandler PrintDoc.PrintPage, AddressOf PrintDoc_PrintPage
iCurrPage = 0
geladen = True
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If geladen Then
clsSettings.SaveSetting("ComboBox", "dein_Drucker", Me.ComboBox1.SelectedItem.ToString, "DeineConfigDatei.xml")
End If
End Sub
End Class