In the last How to find the ReportObjects in Crystal Report using Crystal Reports .NET SDK? I discussed about ReportObject and various objects that inherits some of the properties of ReportObject with this blog I would like to highlight some the things that can be done to TextObject, in order words let’s see what all properties can be explored and used in the project.
TextObject represents a text object found in a report. The namespace that contains it is CrystalDecisions.CrystalReports.Engine.
Crystal Report’s Designer offers extensive properties than what SDK offers, but these properties can be used to add borders, change fonts and some of the common properties seen in Format Editor. So let’s start with the first code changing font and adding border around the object:
Sample Code for Customizing the TextObject |
---|
private void ChangeTextObjectsPropeties() { ReportDocument rd = new ReportDocument(); TextObject txtObj; rd.Load(Server.MapPath("CrystalReports.rpt")); Font fp = new Font("Tahoma", 10);
txtObj = (TextObject)(rd.ReportDefinition.ReportObjects["Text2"]); if (txtObj != null) { txtObj.ApplyFont(fp); Border bdtxt = txtObj.Border; bdtxt.BorderColor = Color.Red; bdtxt.BottomLineStyle = LineStyle.DotLine; } CrystalReportViewer1.ReportSource = rd; } |
Next code is dealing with some of the common properties of Format Editor:
Sample Code Changing the Common Properties of TextObject |
---|
private void ChangeTextObjectsPropeties2() { ReportDocument rptDoc = new ReportDocument(); rptDoc.Load(Server.MapPath("rystalReports.rpt")); TextObject txtObj; txtObj = (TextObject)(rd.ReportDefinition.ReportObjects["Text2"]); if (txtObj != null) { txtObj.ObjectFormat.EnableCanGrow = true; txtObj.ObjectFormat.EnableKeepTogether = true; txtObj.ObjectFormat.HorizontalAlignment = Alignment.LeftAlign;
} } |
There are more properties which can be used when ObjectFormat is used, like:
How come I miss the properties it inherits from ReportObject, these are some the those which can be used to get or set the height, width, upper top or left position etc…
We can manipulate some of the properties using the code given above. I don’t want to miss the point here that it’s all ReportDocument Object Crystal Reports .NET Applications and Object Models used which comes in the picture while doing the stuff mentioned above.
I see many advantages here and some of them are:
Though these properties are not really extensive but are powerful enough to help you personalize your application at runtime.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |