Page 1 of 1
Prompting to Save Report When Closing Viewer
Posted: Wed Jul 18, 2007 10:39 pm
by fphealthcare
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
Prompting to Save Report When Closing Viewer
Posted: Thu Jul 19, 2007 2:31 am
by Edward
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.
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:
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;
}
Please note that static events should be assigned only once in your application.
Thank you.
Prompting to Save Report When Closing Viewer
Posted: Thu Jul 19, 2007 3:52 am
by Edward
We will add a new property which allows do not save the report modified when StiDesigner.DontAskSaveReport = true.
Thank you.
Prompting to Save Report When Closing Viewer
Posted: Thu Jul 19, 2007 5:41 pm
by fphealthcare
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:
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;
}
Please note that static events should be assigned only once in your application.
Thank you.
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?
Can we do this?
Prompting to Save Report When Closing Viewer
Posted: Sun Jul 22, 2007 11:42 am
by Edward
Please use the following code:
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);
}
}
Thank you.
Prompting to Save Report When Closing Viewer
Posted: Sun Jul 22, 2007 10:53 pm
by fphealthcare
Edward wrote:Please use the following code:
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);
}
}
Thank you.
We have added the code but have been getting an error.
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
Posted: Mon Jul 23, 2007 1:14 am
by Edward
You should add the following namespace to your application:
The FormClosingEventArgs is declared in this namespace.
Thank you.