Hi 11062125,
First, you can get the list of all printers attached to your PC and fill the values into a list.
Then you can choose one via its name as a default Printer.
Please refer to the following code:
private void listAllPrinters()
{
foreach (var item in PrinterSettings.InstalledPrinters)
{
this.listBox1.Items.Add(item.ToString());
}
}
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
{
string pname = this.listBox1.SelectedItem.ToString();
myPrinters.SetDefaultPrinter(pname);
}
public Form1()
{
InitializeComponent();
listAllPrinters();
}
}
public static class myPrinters
{
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool SetDefaultPrinter(string Name);
}
You can also explore it from the PrintDialog point of view.
Here is a related thread and hope helpful for you.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.