How to cancel printing process

Stimulsoft Reports.NET discussion
Post Reply
UmutOzkan
Posts: 6
Joined: Fri Sep 17, 2010 7:50 am
Location: Turkey

How to cancel printing process

Post 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...

Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to cancel printing process

Post by Alex K. »

Hello,

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

Thank you.
UmutOzkan
Posts: 6
Joined: Fri Sep 17, 2010 7:50 am
Location: Turkey

How to cancel printing process

Post by UmutOzkan »

Will you add new version this behavior?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to cancel printing process

Post 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.
UmutOzkan
Posts: 6
Joined: Fri Sep 17, 2010 7:50 am
Location: Turkey

How to cancel printing process

Post 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 ;)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to cancel printing process

Post 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.
Post Reply