Page 1 of 1

Saving Report from stream

Posted: Tue Mar 20, 2007 5:03 pm
by mmurdock
I'm not sure if current beta builds fix this, but currently I am loading reports from a database and when I click "save" it wants to save the report as a file and also it does this when I close a report and it asks me if I want to save or cancel changes. I would like it to save back to the database instead. Any suggestion on how to do this would be appreciated.

Thanks,

Mat

Saving Report from stream

Posted: Wed Mar 21, 2007 1:31 am
by EDV Gradl
Use some code like this:

StiDesigner.SavingReport += new StiSavingObjectEventHandler(StiDesigner_SavingReport);

...


private void StiDesigner_SavingReport(object sender, StiSavingObjectEventArgs e)
{
if (this.MyReport.IsModified)
{
// Save report

}
}

I hope that helps.

I found it easier to use the save the string methods, but is just my two cents.

Marco

Saving Report from stream

Posted: Wed Mar 21, 2007 9:01 am
by Vital
This is a right way.

Saving Report from stream

Posted: Wed Mar 21, 2007 9:25 am
by mmurdock
Can you give your example in vb.net? Is this event in the current version or is it in one of the betas?

Mat

Saving Report from stream

Posted: Wed Mar 21, 2007 10:05 am
by Edward
This event handler exists from the StimulReport.Net version 2006.4 and todays beta versions also contains this event.

Please see the code in Vb.Net

Code: Select all

Private report As StiReport = New StiReport

AddHandler StiDesigner.SavingReport, New StiSavingObjectEventHandler(AddressOf Me.On_SavingReport)

Private Sub On_SavingReport(ByVal sender As Object, ByVal e As StiSavingObjectEventArgs)
      'If possible you may get the report object here
      'Dim report As StiReport = TryCast(sender,StiDesigner).Report
      If (report.IsModified) Then
         report.Save("d:\MyReport.mrt")
      End If 
End Sub
Thank you.

Saving Report from stream

Posted: Wed Mar 21, 2007 3:11 pm
by mmurdock
I'm getting a "savingreport" is not an event. What all do I need to have in my "imports"section to get that event.

Thanks,

Mat

Saving Report from stream

Posted: Thu Mar 22, 2007 2:08 am
by Edward
You should add the following into Imports section of your Application:

Code: Select all

Imports Stimulsoft.Report.Design
then you can add your custom event handler On_SavingReport to the static event of the StiDesigner class.

Please note that this event is exists on the class level, not on the instance of the StiDesigner. And you should add an event handler to the StiDesigner.SavingReport only once. The best way if you do this in the event handlers of the events like Load of the main Form of your project.

Thank you.