Page 1 of 1
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Fri Aug 27, 2010 4:33 am
by stvhui
Hello to you,
I'm newbie using VB.NET 2005, Stimulsoft Report 2010 for .NET Winform
As we know, when report showing on viewer, Viewer have a print button, when clicked then the PRINT DIALOG show, If user pressing PRINT button, then report printing on printer.
How to detect it, when PRINT button pressed then msgbox("PRINTING")
Please guide me and show me by code in VB.NET
Thanks in advance
Regards,
Steven
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Mon Aug 30, 2010 8:16 am
by Ivan
Hello,
Please check the following article in our knowledgebase:
http://stimulsoft.helpserve.com/index.p ... icleid=104
You should use the static PrintingDocument event of the StiPreviewControl class.
See a code below for processing printing of a rendered report:
Code: Select all
AddHandler StiPreviewControl.PrintingDocument, New EventHandler(AddressOf Form1.OnPrintingDocument)
Code: Select all
Private Shared Sub OnPrintingDocument(ByVal sender As Object, ByVal e As EventArgs)
' Show your messagebox here
Dim Report As StiReport = TryCast(sender, StiReport)
Report.Print()
End Sub
Thank you.
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Mon Aug 30, 2010 10:43 pm
by stvhui
Hi Ivan,
Thanks for yr reply.
Yr solution is just detected pressing PRINT button at ReportViewer Control, that is not my point.
My point is : After pressing PRINT button at ReportViewer Control, then The PRINT DIALOG Window showing, this window contains 2 buttons [OK] and [CANCEL].
I just want to detected if pressing/clicking [OK] button.
I'm existing user of DataDynamics, Now GrapeCity Active Report. They have knowledge base/documentation about this.
Please advice and show by code
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Tue Aug 31, 2010 1:08 am
by Ivan
Hello,
Please check the following article in our knowledgebase:
http://stimulsoft.helpserve.com/index.p ... ticleid=27
How to know which buttons press user in print dialog box?
You can check property - report.PrinterSettings.PrintDialogResult. See sample below.
Code: Select all
if (report.CompiledReport != null)
return report.CompiledReport.PrinterSettings.PrintDialogResult
else
return report.PrinterSettings.PrintDialogResult;
Thank you.
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Tue Aug 31, 2010 4:58 am
by stvhui
Hello Ivan,
Great!, that's what I want.
I want to code, when After pressing [OK] button at PRINT DIALOG window, then immediately to showing msgbox("PRINTING to PRINTER")
What event should I coded in?
Please advice & show me how?
Thanks
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Tue Aug 31, 2010 10:06 am
by Alex K.
Hello,
You can use the following code:
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
StiReport report = new StiReport();
report.Load("D:\\Sample Report.mrt");
report.Compile();
report.CompiledReport.Printed += new EventHandler(report_Print);
report.Show();
}
private void report_Print(object sender, EventArgs e)
{
StiReport report = sender as StiReport;
if ((report.PrinterSettings.PrintDialogResult == DialogResult.OK))
{
MessageBox.Show("PRINTING to PRINTER");
}
}
Thank you.
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Tue Aug 31, 2010 9:23 pm
by stvhui
Hi Aleksey,
Thanks for yr answer, You fullfil what I want.
One more questions, from yr code :
report.compile()
Should always have this line? (because, If not put report.compile seems report also work)
When report.compile needed?
Thanks in advance
Steven
How to detect if the-user pressing PRINT button at PRINT DIALOG?
Posted: Wed Sep 01, 2010 1:21 am
by Alex K.
Hello,
In this case the report.compile() method is used to assign the report.CompiledReport.Printed += new EventHandler(report_Print); event.
Thank you.