Hi there,
i have a problem setting a datarelation of the report by code. Problem is, when i open the Report with m_Stireport1.Design the Datarelation is not shown at my datasources.
Here is the example.
m_StiReport = New Stimulsoft.Report.StiReport
m_StiReport.Load(path)
Dim o As Object = m_StiReport.Dictionary.Relations.Clone()
m_StiReport.Dictionary.Databases.Clear()
m_StiReport.Dictionary.DataSources.Clear()
m_StiReport.Dictionary.Relations.Clear()
m_StiReport.RegData(m_Dataset)
m_StiReport.Dictionary.Synchronize()
m_StiReport.Dictionary.Relations = DirectCast(o, Stimulsoft.Report.Dictionary.StiDataRelationsCollection)
m_StiReport.Dictionary.RegRelations()
m_StiReport.Design()
Do i have to start "m_StiReport.Dictionary.Synchronize()" before setting the relation or after that ?.
Thx for your help.
Stephan
Edit:
I checked the code in the designer and i found that the relation is in the code. But it's not visible at my Datasources.
Private Sub InitializeComponent()
Me.WaWi_VKBelegePositionen = New WaWi_VKBelegePositionenDataSource
Me.WaWi_VKBelegeSeriennummern = New WaWi_VKBelegeSeriennummernDataSource
Me.ParentBelPoszuSrn = New Stimulsoft.Report.Dictionary.StiDataRelation("BelPoszuSrn", "BelPoszuSrn", "BelPoszuSrn", Me.WaWi_VKBelegePositionen, Me.WaWi_VKBelegeSeriennummern, New System.String() {"ID"}, New System.String() {"BelegPosID"})
Problem with Datarelation by code
Problem with Datarelation by code
Hi Stephan,
The typical code for creation relations from code looks like follows:
Please also check that there is no relations with repeated names in your report.
Thank you.
The typical code for creation relations from code looks like follows:
Code: Select all
StiReport report = new StiReport();
report.Load("D:\\relations.mrt");
DataSet ds = new DataSet("Demo");
ds.ReadXml("D:\\demo.xml");
report.RegData(ds);
report.Dictionary.Synchronize();
StiDataRelation dataRelation = new StiDataRelation("MyRelation", report.Dictionary.DataSources["Categories"], report.Dictionary.DataSources["Products"], new System.String[]{"CategoryID"}, new System.String[] {"CategoryID"});
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
Thank you.
Problem with Datarelation by code
Thx Edward,
but for what use is then
Dim o As Object = m_StiReport.Dictionary.Relations.Clone()
m_StiReport.Dictionary.Relations = DirectCast(o, Stimulsoft.Report.Dictionary.StiDataRelationsCollection)
I thougt this is a way to set the Relation as it is set in my report.
Thx
but for what use is then
Dim o As Object = m_StiReport.Dictionary.Relations.Clone()
m_StiReport.Dictionary.Relations = DirectCast(o, Stimulsoft.Report.Dictionary.StiDataRelationsCollection)
I thougt this is a way to set the Relation as it is set in my report.
Thx
Problem with Datarelation by code
Hi Stephan,
You are welcome. Please follow the example and relations will be easily registered!
Thank you.
You are welcome. Please follow the example and relations will be easily registered!
Thank you.