Change printername in PrintDialog through code
Asked Answered
D

1

3

I am attempting to change the selected printer of my PrintDialog through code. I am creating an image that needs to be printed, but the size of the image determines which printer should be used. I have the name of the printer that I want to use but I just can't figure out where to change that value. Any help can be in either VB.NET or C#.

Thanks.

Domella answered 26/3, 2013 at 16:5 Comment(0)
S
5

You should look for the PrinterName Property. This property resides in the PrinterSettings Class. The PrinterSettings class is also a property of the PrintDialog. This way you can access the PrinterSettings and change the PrinterName-property.

//Example for GETTING the printername
var pd = new PrintDialog();
var settings = pd.PrinterSettings;
var name = settings.PrinterName

//Example for SETTING the printername
var pd = new PrintDialog();
pd.PrinterSettings.PrinterName = "YOUR_PRINTER_NAME";

Hope this helps.

Siegfried answered 26/3, 2013 at 16:18 Comment(1)
That was exactly what I was trying to find. Thank you.Domella

© 2022 - 2024 — McMap. All rights reserved.