In a crystal report, I want to set alignment of a fields accordingly. How can i do the same at run time?
That's nice.This is working.Thanks.I did same, and 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 I'm going through another problem now.
FieldObject fo = rpt.ReportDefinition.ReportObjects["InvoiceComment"] as FieldObject;
OR
var fo = rpt.ReportDefinition.ReportObjects["InvCom"];
Are showing same error "Index was outside the bounds of the array." And if I use Another code instead of that it works.
FieldObject fo = rpt.ReportDefinition.ReportObjects[35] as FieldObject;
How to encurr this. Thanks in Advance.
in C#:
possible choices:
I used text interpretation = RTF Text and set value in rich text format and my problem is solved... I designed better crystal report dynamically using RTF.
To change the Horizontal Alignment of the field follow the below mentioned steps:
1) Right click on the field.
2) Click on Format Field Option.
3) Select the Common Tab.
4) Click the formula editor in front of Horizontal Alignment and add the setting required.
5) Following are the Alignment constants available:
Constant
use it as per your criteria.