Page 1 of 2
Capturing report new and report open events in the report designer
Posted: Tue Feb 13, 2007 4:43 pm
by jing
Hi,
How do I capture the event when the user is creating a new report and when the report open button is pushed in the Report Designer?
I would like to reset the database connection when that happens.
thanks
Capturing report new and report open events in the report designer
Posted: Tue Feb 13, 2007 6:35 pm
by jing
Ok, I managed to capture the event when the report open button is pushed.
Here is my code:
Code: Select all
AddHandler Stimulsoft.Report.Design.StiDesigner.LoadingReport, AddressOf TestFunction
Private Sub TestFunction(ByVal sender As Object, ByVal e As Stimulsoft.Report.Design.StiLoadingObjectEventArgs)
If OpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim designer As Stimulsoft.Report.Design.StiDesigner = sender
designer.Report.Dictionary.Clear()
designer.OpenFile(OpenFileDialog.FileName)
Dim database As Dictionary.StiSqlDatabase = designer.Report.Dictionary.Databases("Exonet")
database.ConnectionString = "Data Source=" & db.Server & ";Initial Catalog=exonet_copy619;User Id=" & db.UserID & ";Password=" & db.Password
End If
End Sub
It works fine except that when I try to create a new report by pushing the "New Report" button, the database connection string is still set to the report I opened before.
I need the database connection to set to the orginal settings (ie. When I opened the designer originally, I set it to point at database "x_exonet"). How can I get around this?
thanks
Capturing report new and report open events in the report designer
Posted: Thu Feb 15, 2007 10:41 am
by Edward
So if I understood in the right way you need to set a previous Connection for the report which will be created after pressing the New Report button?
Please describe with more detail.
Thank you.
Capturing report new and report open events in the report designer
Posted: Thu Feb 15, 2007 1:37 pm
by jing
I would like to set a new database connection after pressing the New Report button - so I need to have control over the new report event I think.
Can this be done?
thanks
Capturing report new and report open events in the report designer
Posted: Thu Feb 15, 2007 10:01 pm
by jing
Futher on report open button event,
Does StiDesigner.LoadingReport only called when I click the open button in the Designer?
Because for some reason the event is sometimes called multiple times.... I can't find a pattern to it, sometimes it happens, sometimes it doesn't.
I suspect it's something to do with the designer, When I called designer.OpenFile(reportfilename) or designer.report.load(reportfilename)...
Is there a way to determine when the report has finished loading in the designer? I can put a thread to sleep while it is loading to stop it calling the event !!
Any help on this will be great (Also, is there a documentation on all methods?)
Thanks
Capturing report new and report open events in the report designer
Posted: Fri Feb 16, 2007 11:23 pm
by Vital
jing wrote:Futher on report open button event,
Does StiDesigner.LoadingReport only called when I click the open button in the Designer?
Because for some reason the event is sometimes called multiple times.... I can't find a pattern to it, sometimes it happens, sometimes it doesn't.
I suspect it's something to do with the designer, When I called designer.OpenFile(reportfilename) or designer.report.load(reportfilename)...
Is there a way to determine when the report has finished loading in the designer? I can put a thread to sleep while it is loading to stop it calling the event !!
Any help on this will be great (Also, is there a documentation on all methods?)
Thanks
If you add event handler to LoadingReport event then standard event handler is skipped. If you need call standard event handler you need add following code:
If you want fully process this operation then you need manually load report to designer.
Thank you.
Capturing report new and report open events in the report designer
Posted: Fri Feb 16, 2007 11:40 pm
by Vital
We have added following static events:
Code: Select all
StiDesigner.LoadedReport//Occurs only if report loaded successfully
StiDesigner.SavedReport//Occurs only if report saved successfully
StiDesigner.CreatedReport//Occurs only if report created successfully
StiDesigner.CreatingReport
Thank you.
Capturing report new and report open events in the report designer
Posted: Sun Feb 18, 2007 1:48 pm
by jing
We have added following static events:
StiDesigner.LoadedReport//Occurs only if report loaded successfully
StiDesigner.SavedReport//Occurs only if report saved successfully
StiDesigner.CreatedReport//Occurs only if report created successfully
StiDesigner.CreatingReport
Which build contains these events? I am using build StimulReport.Net 2007.02.16 R2005 and I can't see these events yet.
If you want fully process this operation then you need manually load report to designer.
I am doing this, but the LoadingReport is sometimes called multiple times - I only needed to call it once (I don't quite understand why it is sometimes called multiple times) ... Here is my code
Code: Select all
AddHandler Stimulsoft.Report.Design.StiDesigner.LoadingReport, AddressOf OpenMyReportFile
Private Sub OpenMyReportFile(ByVal sender As Object, ByVal e As Stimulsoft.Report.Design.StiLoadingObjectEventArgs)
If _loadingReport = False Then
_loadingReport = True
Dim dialogR As Windows.Forms.DialogResult = Nothing
dialogR = MyOpenFile.ShowDialog
If dialogR = Windows.Forms.DialogResult.Cancel Then
_loadingReport = False
Exit Sub
End If
If dialogR = Windows.Forms.DialogResult.OK Then
Dim designer As Stimulsoft.Report.Design.StiDesigner = sender
designer.Report.Dictionary.Clear()
designer.Report.Load(MyOpenFile.FileName)
For Each d As Dictionary.StiSqlDatabase In designer.Report.Dictionary.Databases
d.ConnectionString = "Data Source=" & db.Server & ";Initial Catalog= " & db.Database & ";User Id=" & db.UserID & ";Password=" & db.Password
Next
_loadingReport = False
End If
End If
End Sub
Any help on this please
Capturing report new and report open events in the report designer
Posted: Sun Feb 18, 2007 4:16 pm
by Vital
Sorry, build will be available only today.
We will check problem with multiple events running.
Thank you.
Capturing report new and report open events in the report designer
Posted: Mon Feb 19, 2007 6:09 am
by Edward
Please define a static constructor for your form (for example Form1). It is gets a guarantee that Event Handler OpenMyReportFile will be added to the static event StiDesigner.LoadingReport only once.
Code: Select all
Shared Sub New()
AddHandler StiDesigner.LoadingReport, New StiLoadingObjectEventHandler(AddressOf Form1.OpenMyReportFile)
End Sub
Thank you.