Page 1 of 1

How to cancel printing process

Posted: Fri Sep 17, 2010 9:29 am
by UmutOzkan
Hi.

When clicked print button i checking some values and decide cancel printing or no.

i tried on printing event

ReportViewer.Report.IsStopped = true;
ReportViewer.Report.IsPrinting = false;
ReportViewer.Report.Stop = true;

but anyway reportviewer showing windows print dialog...


How to cancel printing process

Posted: Mon Sep 20, 2010 1:57 am
by Alex K.
Hello,

Unfortunately, if the task is sent for printing, then it is not possible to cancel this action.

Thank you.

How to cancel printing process

Posted: Mon Sep 20, 2010 2:03 am
by UmutOzkan
Will you add new version this behavior?

How to cancel printing process

Posted: Mon Sep 20, 2010 7:47 am
by Alex K.
Hello,

Unfortunately, in this case it is impossible to add something, if control is passed to the print dialog box, the window is controlled with Windows, not a designer, and somehow to change this is not possible.
Alternatively, in this case, you can, in your application code, to check the condition and depending on the result, to hide or show the print button.
How to hide a button in the viewer you can view the article in our KnowledgeBase at
http://stimulsoft.helpserve.com/index.p ... icleid=105

Thank you.

How to cancel printing process

Posted: Mon Sep 20, 2010 8:44 am
by UmutOzkan
If "Printing" event triggered before than windows print dialog, component can take boolean value from user and decide show this dialog or no.
Whatever. Thanks for interest ;)

How to cancel printing process

Posted: Tue Sep 21, 2010 1:57 am
by Alex K.
Hello,

You can only, instead of cancel, skip or do not skip the Print dialog box, for this you need to subscribe to the PrintingDocument event of the viewer:

Code: Select all

StiReport report = new StiReport();
report.Load("e:\\Report.mrt");
StiViewerControl.PrintingDocument +=new EventHandler(StiViewerControl_PrintingDocument);
report.Show();

private static void StiViewerControl_PrintingDocument(object sender, EventArgs e)
{
      StiReport report = sender as StiReport;
      if (IsPrint)
      {
           report.Print();
      }
}

Thank you.