How to dynamically add fields in crystal reports

xiaoxiao2021-03-06  62

Problem: In the crystal report, because the field of the data source is not fixed, can you dynamically add a field when running, just like the dynamic add control in WinForm? (Update: 2003-11-05) -------------------------------------- Solution: Use the "Formula Field" 1, depending on the maximum number of fields, define a number of "formula fields", formulafeild1, formulafeild2 ..., formula is empty; 2, put "formula field" in order in order "detailed information"; Dynamically assign the "formula field" to "specific field" in the program; for formulafield1.text = "{Customer. Customer ID}" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------ Reference: 1, retrieve the DATADEFINITION object via the ReportDocument object's DATADEFINIT attribute. ReportDocument member public instance attribute DATADEFINITION DATADEFINITION. Get the DATADEFINITION object.

2, DataDefinition class DataDefinition members | CrystalDecisions.CrystalReports.Engine namespace requirement namespaces: CrystalDecisions.CrystalReports.Engine Platform: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Assembly: CrystalDecisions.Crystalreports.Engine ( In CrystalDecisions.crystalReports.Engine.dll) contains all information related to data operations (data operations in accordance with the data source in the report). For a list of all members of this type, see the DATADEFINITION member. Object DataDefinition Remarks You can use this class to define as a report and group selection records, and you can also retrieve group collections and various field definitions. Retrieve the DataDefinition object by the DATADEFINITION property of the ReportDocument object.

3. Retrieve the formulafields object through the formulafielddefinitions property of the DATADEFINITION object. DataDefinition member DATADEFINITION Class | CrystalDecisions.crystalReports.Engine Namespace Public Instance Properties Formulafields FormulafieldDefinitions. Get the FormulafieldDefinitions collection.

4, FormulaFieldDefinitions class FormulaFieldDefinitions members | CrystalDecisions.CrystalReports.Engine namespace requirement namespaces: CrystalDecisions.CrystalReports.Engine Platform: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Assembly: CrystalDecisions.Crystalreports.Engine ( In CrystalDecisions.crystalReports.Engine.dll) The formulafieldDefinition objects containing each formula field in the report. For a list of all members of this type, see FormulafieldDefinitions members. Object Scrcollection FormulaFieldFieldDefinitions Retrieves the FormulafieldDefinitions collection through the formulafields attribute of the DATADEFINIT object. 5, get the FormulafieldDefinition object, and set the formula. For example: formulafielddefinition.text = "{customer. Customer ID}"

FormulafieldDefinition Class | CrystalDecisions.crystalReports.Engine Namespace Public Instance Properties Formulaname (inherited from FieldDefinition) String. Get the field definition unique formula name in the Crystal Report formula syntax. Kind (inherited from FieldDefinition) fieldkind. Get the type of field. Name string. Get the formula field name displayed in Field Explorer. Numberofbytes (inherited from FieldDefinition) INT32. Get the number of bytes required to store field data in memory. TEXT string. Get or set the text of the formula. Usecount (inherited from FieldDefinition) INT32. Get the number of times a field used in the report. ValueType (inherited from FieldDefinition) FieldValueType. Get the type of field value. Public example method Check check formula. If there is a speech error, the error string and false are returned.

转载请注明原文地址:https://www.9cbs.com/read-119537.html

New Post(0)