MessageBox.Show("Could not set selected printer to default.", "Error. If ComboBox1.SelectedIndex > -1 AndAlso ps.PrinterName Then Private Sub Button_SetDefaultPrinter_Click(sender As Object, e As EventArgs) Handles Button_SetDefaultPrinter.Click Private Shared Function SetDefaultPrinterW( ByVal pszPrinter As String) As Booleanįor Each p As String In PrinterSettings.InstalledPrinters You can then select another printer in the ComboBox and then press the Button to set it as the default printer. If you say it can`t be done then i`ll try it Now from the left side panel or menu select Printer & Scanner. From Windows, Settings click on the Devices button.
Or Just click on the Gear icon given but above the Power icon in Windows 10 startup menu. Imports Imports Public Class Form1 Private Shared Function SetDefaultPrinterW( ByVal pszPrinter As String) As Boolean End Function Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList For Each p As String In PrinterSettings.InstalledPrinters (p) Next Dim ps As New PrinterSettings ComboBox1.SelectedItem = ps.PrinterName End Sub Private Sub Button_SetDefaultPrinter_Click(sender As Object, e As EventArgs) Handles Button_SetDefaultPrinter.Click Dim ps As New PrinterSettings If ComboBox1.SelectedIndex > -1 AndAlso ps.PrinterName Then If Not SetDefaultPrinterW() Then MessageBox.Show("Could not set selected printer to default.", "Error.") End If End If End Sub End Class Change or Set the default printer in Windows 10 Open Windows 10 Settings for that keyboard shortcut is Windows key + i.
Below is an example, it loads the names of the installed printers into a ComboBox and selects the current default printer when the form loads.
You could also use the Win32 SetDefaultPrinter function to set the default printer by its name. MessageBox.Show("Nothing is selected in ComboBox1." & vbCrLf & "Please select a printer in ComboBox1 dropdown and try again")
Printer.InvokeMethod("SetDefaultPrinter", CType(args(0), Object()))ĮlseIf ((-1)) Then If printer("Name").ToString = ComboBox1.Text Then Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChangedįor Each printer As Management.ManagementObject In results Search = New ("select * from win32_printer")Ĭ(printer("Name").ToString)Ĭ(printer.Item("Default").ToString) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Imports System.Management ' Add reference, Project Tab, Add reference, Assemblies, Framework, check System.Managementĭim search As ĭim results As
The code in the ComboBox SelectedIndex Changed event can be used in some other event (Button Click) by providing a string for the printer name in question rather than using "ComboBox1.Text".