P
Phil Galey
The documentation for IsDefaultPrinter states that it works only if the PrinterName property is null. So if you're looping through the list of installed printers, how do you use IsDefaultPrinter to determine whether each one is the default printer? In the following code, I'm filling a checked listbox with printer names and try to check only the one that is the default printer. The IsDefaultPrinter property returns true for all of them because I'm not specifying the PrinterName. The documentation says that if I do specify PrinterName, IsDefaultPrinter will
always return False.
-----------------------------------------------------------------------------------------
Dim ptr As String, ptrs As String
Dim pd As New PrintDialog()
pd.Document = New Printing.PrintDocument()
For Each ptr In pd.PrinterSettings.InstalledPrinters
'pd.PrinterSettings.PrinterName = ptr <== Forbidden
clbPrinters.Items.Add(ptr, pd.PrinterSettings.IsDefaultPrinter)
Next
always return False.
-----------------------------------------------------------------------------------------
Dim ptr As String, ptrs As String
Dim pd As New PrintDialog()
pd.Document = New Printing.PrintDocument()
For Each ptr In pd.PrinterSettings.InstalledPrinters
'pd.PrinterSettings.PrinterName = ptr <== Forbidden
clbPrinters.Items.Add(ptr, pd.PrinterSettings.IsDefaultPrinter)
Next