-3

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!

2
  • Adding "instant" as a tag and also "visual studio" (which has got nothing to do with this question other than you using it as the IDE), yet failing to add the "winforms" tag? Also, did you even try to Google this?
    – BCdotWEB
    Commented Jul 6, 2015 at 7:34
  • I've tried to google it. And I also changed some tags for you :* Have a nice day! :))
    – Gorsky
    Commented Jul 6, 2015 at 8:09

1 Answer 1

2

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.

1
  • It looks like an answer. Thank you very much I will try that as soon as I can. Hope it works.
    – Gorsky
    Commented Jul 6, 2015 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.