on 2018 Aug 29 9:26 PM
Hi
We are trying to set the "Object Name" of a subreport using C#. The Name property shows as get; set and accepts the string value we set. But when the report is saved with the C# code and checked in designer, it still shows "Subreport1".
Code Sample below works fine but when the report is opened using Crystal Reports Designer it shows that the object name is still "Subreport1":
CrystalDecisions.CrystalReports.Engine.ReportDocument Mainrd;
string RPTPath = @"C:\Main.rpt";
Mainrd.Load(RPTPath);
ReportObjectController rptObjCtrl = Mainrd.ReportClientDocument.ReportDefController.ReportObjectController;
rptObjCtrl.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindSubreport)[0].Name = "TestSub";
Mainrd.SaveAs(RPTPath);
Mainrd.Close();
We are using:
Runtime: "13.0.20.2399"
Visual Studio 2017
Are we doing something wrong here? Please let us know. Appreciate your help!
Regards
Nikhil
Request clarification before answering.
To be able to change the name normally you would use RAS and it's a read only property:
string Name { get; }
Member of CrystalDecisions.ReportAppServer.Controllers.ISCRSubreportClientDocument
What you would have to do is Clone the subreport and change it's name and then delete the old one and add the cloned object back into the report.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
21 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.