Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top