Symptom
We want to get/set the Size and Position of an object using Crystal Reports for Visual Studio.
Using the following they always return null:
- rptobj.Format.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDeltaWidth]
- rptobj.Format.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeDeltaX]
Environment
Crystal Reports for Visual Studio, all versions
Resolution
R&D looked into this but determined it's too much work to impliment using the .NET SDK.
At this time you will need to use the Report Designer to adjust the location of the object.
There are otherr ways to accomplish this though:
Here is an example, from my Parameter test app, to get/set the top/left corner of the object:
case CrReportObjectKindEnum.crReportObjectKindBox:
CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject boxObj1;
CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject boxObj2 = new CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject();
boxObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject)rptObj1;
boxObj2 = boxObj1;
//// modify the box size, note values are in Twips - 1 inch = 1440 twips.
boxObj.Bottom = 360;
boxObj1.Height = 2385;
boxObj1.Format.EnableCanGrow = true;
boxObj1.EndSectionName = "ReportFooterSection1";
boxObj1.EnableExtendToBottomOfSection = true;
rptClientDoc.ReportDefController.ReportObjectController.Modify(boxObj, boxObj1);
btnReportObjects.Text += "Name: " + boxObj1.Name.ToString() + " -> ";
btnReportObjects.Text += boxObj1.Name.ToString() + " : X - " + (boxObj1.Left / 1440.00).ToString() + " : Y - " + ((boxObj1.Right - boxObj1.Left) / 1440.00).ToString();
btnReportObjects.Text += "\n Width - " + (boxObj1.Width / 1440.00).ToString() + "\n Height - " + (boxObj1.Height / 1440.00).ToString() + "\n";
btnReportObjects.Text += "Section Name: " + rptObj1.SectionName.ToString() + "\n";
btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");
++flcnt;
btnCount.Text = flcnt.ToString();
IsRpt = false;
break;
Keywords
CR for VS, Size and Position, crObjectFormatConditionFormulaTypeDeltaWidth, crObjectFormatConditionFormulaTypeDeltaX , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem