Is there any method to print a document just by pressing PRINT button? I have to choose the printer first in order to proceed but I need to do this instantly.
[WindowsFormsApp]
Thanks!
Is there any method to print a document just by pressing PRINT button? I have to choose the printer first in order to proceed but I need to do this instantly.
[WindowsFormsApp]
Thanks!
I need 50 reputation to write comments, so i will write an answer.
As i can asume you are using the PrintDialog Class, try using the PrintDocument Class. Further information for the PrintDocument Class: https://msdn.microsoft.com/de-de/library/system.drawing.printing.printdocument(v=vs.110).aspx
With the PrintDocument Class you can set your printername so you dont have to show the Dialog.
using System.Drawing.Printing;
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = "my printer";
To find your Installed printernames use this:
foreach (string s in PrinterSettings.InstalledPrinters) {
//
}
If you dont want to use the PrintDocument use this:
PrintDialog pd = new PrintDialog();
pd.PrintQueue = new PrintQueue(new PrintServer(), "printer name" );
But you have to remove ShowDialog() for this.