Saving Report from stream

Stimulsoft Reports.NET discussion
Post Reply
mmurdock
Posts: 94
Joined: Tue Mar 20, 2007 4:59 pm

Saving Report from stream

Post 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
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Saving Report from stream

Post 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
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Saving Report from stream

Post by Vital »

This is a right way.
mmurdock
Posts: 94
Joined: Tue Mar 20, 2007 4:59 pm

Saving Report from stream

Post 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
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Saving Report from stream

Post 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.
mmurdock
Posts: 94
Joined: Tue Mar 20, 2007 4:59 pm

Saving Report from stream

Post 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
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Saving Report from stream

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