Change printername in PrintDialog with code

I am trying to change the selected printer of my PrintDialog using code. I create an image to print, but the size of the image determines which printer to use. I have the name of the printer that I want to use, but I just can't figure out where to change this value. Any help could be in VB.NET or C #.

Thanks.

+2
source share
1 answer

You should look for the PrinterName Property . This property is in the PrinterSettings Class . The PrinterSettings class is also a property of PrintDialog . This way you can access the PrinterSettings settings 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.

+4
source

All Articles