Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event
Posted: Tue Aug 11, 2009 10:30 am
My reports are stored in an SQL Database. To open a recent file from the "Recent Files" list I hook the StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner event handler. When I do this I end up with odd results in the dictionary. I either end up with my Data Connection being not connected (a big black "X" over it) or I end up with none of my data sources showing up.
In the first case I am Loading the Report using a function then assigning it to the Designer.Report property like so:
The code above causes a problem. With my data connection in my dictionary.
However if I do the following nothing is loaded into the dictionary.
The above code causes the dictionary to not have ANY dataconnections or datasources at all.
Keep in mind that at this point the designer was already open with a currently registered data connections etc. Also the report I am trying to load always has my registered data connections saved with it.
Also, a quick comment on both of these fragments. I am destroying any open reports first due to the possibility that someone will close the current report before opening a new one. In this case I will need to create a new report as Designer.Report will be null. To make my code more consistent I make sure Designer.Report always starts null before I begin loading a new report.
I am at a loss as how to proceed with this. If you guys could help me that would be great.
In the first case I am Loading the Report using a function then assigning it to the Designer.Report property like so:
Code: Select all
private void GlobalEvents_OpenRecentFileInDesigner(object sender, StiOpenRecentFileObjectEventArgs e)
{
///////////
// Data
///////////
#region Data
StiDesignerControl Designer;
#endregion
///////////
// Code
///////////
#region Code
Designer = (StiDesignerControl)sender;
if (Designer.Report != null)
{
//Destroy Currently Open Report if it Exists
Designer.Report.Dispose();
//Designer.Report = null; //Setting the report to null causes an exception
}
Designer.Report = LoadReport(e.FileName);
}
However if I do the following nothing is loaded into the dictionary.
Code: Select all
private void GlobalEvents_OpenRecentFileInDesigner(object sender, StiOpenRecentFileObjectEventArgs e)
{
///////////
// Data
///////////
#region Data
StiDesignerControl Designer;
#endregion
///////////
// Code
///////////
#region Code
Designer = (StiDesignerControl)sender;
if (Designer.Report != null)
{
//Destroy Currently Open Report if it Exists
Designer.Report.Dispose();
//Designer.Report = null; //Setting the report to null causes an exception
}
//Set Class Property
ReportName = e.FileName;
Designer.Report = new StiReport();
Designer.Report.LoadFromString(LoadReportString());
StiOptions.Designer.DesignerTitle = "POSitive Report Designer - " + ReportName;
StiOptions.Designer.DesignerTitleText = "POSitive Report Designer - " + ReportName;
//Add Variables to Dictiony
MakeParameters(_ReportParams, Designer.Report);
Designer.Refresh();
#endregion
}
Keep in mind that at this point the designer was already open with a currently registered data connections etc. Also the report I am trying to load always has my registered data connections saved with it.
Also, a quick comment on both of these fragments. I am destroying any open reports first due to the possibility that someone will close the current report before opening a new one. In this case I will need to create a new report as Designer.Report will be null. To make my code more consistent I make sure Designer.Report always starts null before I begin loading a new report.
I am at a loss as how to proceed with this. If you guys could help me that would be great.