In the crystal report, I want to set the field alignment accordingly. How can I do the same at runtime?
It's good. It works. Thanks. I did the same and the code is shown below.
var fo = rpt.ReportDefinition.ReportObjects["InvoiceComment"]; fo.ObjectFormat.HorizontalAlignment = Alignment.LeftAlign; if (ds.Tables[0].Rows[0].ItemArray[19].ToString() == "Right") fo.ObjectFormat.HorizontalAlignment = Alignment.RightAlign; else if (ds.Tables[0].Rows[0].ItemArray[19].ToString() == "Center") fo.ObjectFormat.HorizontalAlignment = Alignment.HorizontalCenterAlign;`
But now I'm experiencing another problem.
FieldObject fo = rpt.ReportDefinition.ReportObjects["InvoiceComment"] as FieldObject;
OR
var fo = rpt.ReportDefinition.ReportObjects["InvCom"];
Show the same error "Index was outside the array." And if I use different code instead, it works.
FieldObject fo = rpt.ReportDefinition.ReportObjects[35] as FieldObject;
How to encrypt it. Thanks at Advance.
source share