Prompting to Save Report When Closing Viewer
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Prompting to Save Report When Closing Viewer
After the report has been shown in the desinger, we want to ask the user if they would like to save the report before closing. Is there a way to do this?
We are using report.Render() to render the report, and report.Show() to show the report.
Thanks
We are using report.Render() to render the report, and report.Show() to show the report.
Thanks
Prompting to Save Report When Closing Viewer
When the Designer is Loaded for designing a report the static event StiDesigner.LoadingDesigner is fired. But in that case the designer is not visible on screen while the event is occurring. Anyway you can ask the user in that moment is he going to save a report or not after the report will be designed.fphealthcare wrote:After the report has been shown in the desinger, we want to ask the user if they would like to save the report before closing. Is there a way to do this?
We are using report.Render() to render the report, and report.Show() to show the report.
Here the code sample of such assignment:
Code: Select all
public bool WeSaveTheReport;
StiDesigner.LoadingDesigner +=new EventHandler(StiDesigner_LoadingDesigner);
StiDesigner.SavingReport += new EventHandler(StiDesigner_SavingReport);
public void StiDesigner_LoadingDesigner(object sender, EventArgs e)
{
// Ask the user about later saving and store the result in WeSaveTheReport variable.
StiDesigner.DontAskSaveReport = !WeSaveTheReport;
}
public void StiDesigner_SavingReport(object sender,StiSavingObjectEventArgs e)
{
//Here the code for saving report, because StiDesigner.DontAskSaveReport does not prevent saving of the modified report.
e.Processed = true;
}
Thank you.
Prompting to Save Report When Closing Viewer
We will add a new property which allows do not save the report modified when StiDesigner.DontAskSaveReport = true.
Thank you.
Thank you.
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Prompting to Save Report When Closing Viewer
I am very sorry. I had made a mistake in my typing. I don't want to ask the user if they want to save the report in the desinger, I want to ask them if they want to save in the VIEWER. We use report.Show() to display the report, and we want to ask the user when they close the viewer if they want to save the report or not?Edward wrote:When the Designer is Loaded for designing a report the static event StiDesigner.LoadingDesigner is fired. But in that case the designer is not visible on screen while the event is occurring. Anyway you can ask the user in that moment is he going to save a report or not after the report will be designed.
Here the code sample of such assignment:
Please note that static events should be assigned only once in your application.Code: Select all
public bool WeSaveTheReport; StiDesigner.LoadingDesigner +=new EventHandler(StiDesigner_LoadingDesigner); StiDesigner.SavingReport += new EventHandler(StiDesigner_SavingReport); public void StiDesigner_LoadingDesigner(object sender, EventArgs e) { // Ask the user about later saving and store the result in WeSaveTheReport variable. StiDesigner.DontAskSaveReport = !WeSaveTheReport; } public void StiDesigner_SavingReport(object sender,StiSavingObjectEventArgs e) { //Here the code for saving report, because StiDesigner.DontAskSaveReport does not prevent saving of the modified report. e.Processed = true; }
Thank you.
Can we do this?
Prompting to Save Report When Closing Viewer
Please use the following code:
Thank you.
Code: Select all
using (StiPreviewForm myForm = new StiPreviewForm())
{
(myForm as Form).FormClosing += new FormClosingEventHandler();
myForm.PreviewControl.Report = report;
report.Render();
myForm.ShowDialog();
}
public void myForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("Do you want to store rendered report", "Form Closing Event", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
report.SaveDocument("D:\\MyReport.mdc");
(sender as Form).FormClosing -= new FormClosingEventHandler(myForm_FormClosing);
}
}
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Prompting to Save Report When Closing Viewer
We have added the code but have been getting an error.Edward wrote:Please use the following code:
Thank you.Code: Select all
using (StiPreviewForm myForm = new StiPreviewForm()) { (myForm as Form).FormClosing += new FormClosingEventHandler(); myForm.PreviewControl.Report = report; report.Render(); myForm.ShowDialog(); } public void myForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("Do you want to store rendered report", "Form Closing Event", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { report.SaveDocument("D:\\MyReport.mdc"); (sender as Form).FormClosing -= new FormClosingEventHandler(myForm_FormClosing); } }
The complier complains
"The type or namespace name 'FormClosingEventArgs' could not be found (are you missing a using directive or an assembly reference?)"
How can we fix this?
Prompting to Save Report When Closing Viewer
You should add the following namespace to your application:
The FormClosingEventArgs is declared in this namespace.
Thank you.
Code: Select all
using System.Windows.Forms;
Thank you.