How can I use code to dynamically set text, fields, and other objects in a crystal report?

Source: Internet
Author: User

 

How can I use code to dynamically set text, fields, and other objects in a crystal report?

// VB

First, you must declare an object variable (eg. textobject, fieldobject,...). Of course, it is not a general object,:
Dim xobject as crystaldecisions. crystalreports. Engine. fieldobject (field)
Dim xobject as crystaldecisions. crystalreports. Engine. textobject (text)
Dim xobject as crystaldecisions. crystalreports. Engine. lineobject (line)
Dim xobject as crystaldecisions. crystalreports. Engine. boxobject (rectangular box)
......
Second, you must assign the real object of the crystal report to it, for example:
Xobject = crreport. reportdefinition. reportobjects. Item ("fieldobjectname ")
Xobject = crreport. reportdefinition. reportobjects. Item ("textobjectname ")
Xobject = crreport. reportdefinition. reportobjects. Item ("lineobjectname ")
Xobject = crreport. reportdefinition. reportobjects. Item ("boxobjectname ")
......
Then, you can call its various attributes and methods:

For fieldobject, you can:
1. Set the number of decimal places in the numeric field:
Xobject. fieldformat. numericformat. decimalplaces = 4
2. Set the output type of a Boolean field:
Xobject. fieldformat. booleanformat. outputtype = crystaldecisions. Shared. booleanoutputtype. yesorno
3. Set other formats such as (commonformat, datetimeformat, dateformat, timeformat)

For textobject, you can:
1. Change text:
Xobject. Text = ""
2. Change the font:
Xobject. applyfont (new font ("", 10.0 !))
3. Set the color:
Xobject. Color = color. Red
3. Hide the display:
Xobject. objectformat. enablesuppress = true

For lineobject, you can:
1. Set the line style:
Xobject. linestyle = crystaldecisions. Shared. linestyle. dotline
2. Set the line color:
Xobject. linecolor = color. Blue
3. Set the line width:
Xobject. linethickness = 3
4. Set other formats (such as position (top, left, right, bottom) and border)
     
For boxobject, you can:
1. Set the fill color:
Xobject. fillcolor = color. Brown
2. Set the line style:
Xobject. linestyle = crystaldecisions. Shared. linestyle. dotline
3. Set the line color:
Xobject. linecolor = color. Blue
4. Set the line width:
Xobject. linethickness = 3
5. set other formats (such as position (top, left, right, bottom) and border)

 

// C #

Crystaldecisions. crystalreports. Engine. textobject xobject;
Xobject = (crystaldecisions. crystalreports. Engine. textobject) crystalreportsource1.reportdocument. reportdefinition. reportobjects ["text1"];
Xobject. Text = "condition ";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.