2021348 - Modifying a Picture object in .NET ignores Object.Height and Object.Width when setting Condition Formula Can Grow is enabled

SAP Knowledge Base Article - Public

2021348 - Modifying a Picture object in .NET ignores Object.Height and Object.Width when setting Condition Formula Can Grow is enabled

Symptom

When modifying an existing picture object and using a formula to update the image file location and name using the .Modify() method the image is not sizing accordingly.

Environment

  • Crystal Reports for Visual Studio
  • VS 2010
  • VS 2012
  • VS 2013

Cause

  • This issue has been tracked with ADAPT01727457 and scheduled for SP 11 ( possibly SP 10 ).
  • Work-around:
 You can do this all dynamically and creatively as you wish but the basics to updating the image is as follows:
CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject boPictureObject = new CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject(); ;
string strNewImageFilename = "D:\\Atest\\DSC_2655.jpg";
foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject oReportObject in objects)
{
if (oReportObject.Kind == CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture)
{
var oPlaceholderPicture = oReportObject as CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject;
if (oPlaceholderPicture != null)
{
// clone the original object so it can be modified
var oNewPicture = (CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject)oPlaceholderPicture.Clone(true);
var cf = new CrystalDecisions.ReportAppServer.ReportDefModel.ConditionFormula();
PicFileLocationFormula.Text = "\"" + strNewImageFilename + "\"";
oNewPicture.Format.EnableCanGrow = false;
oNewPicture.GraphicLocationFormula = PicFileLocationFormula;
oNewPicture.Width = 4320; // 3 inches
oNewPicture.Height = 1440; // 1 inch
rptClientDoc.ReportDefController.ReportObjectController.Modify( oPlaceholderPicture, oNewPicture );
// Call the Modify again to update the CanGrow flag to false - default is set to True
oNewPicture.Format.EnableCanGrow = false;
rptClientDoc.ReportDefController.ReportObjectController.Modify(oPlaceholderPicture, oNewPicture);
}
}
}

Resolution

The issue is resolved in Service Pack 10 for SAP Crystal Reports, Developer Version for Visual Studio .NET.

Keywords

Modifying a Picture object in .NET, Object.Height, Object.Width, image, jpeg, bmp, crystal reports for visual studio, crforvs, Condition Formula, Can Grow , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2005 ; SAP Crystal Reports, version for Visual Studio .NET 2008