FormulaFieldDefinition Class
Provides properties and methods for retrieving information and setting options for any named formula field in a report.
Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)
Syntax
'Declaration
Public Class FormulaFieldDefinition
Inherits FieldDefinition
Implements IDisposable
public class FormulaFieldDefinition : FieldDefinition, IDisposable
Remarks
Formulas are supported in Crystal Reports syntax and Visual Basic syntax. The default syntax is Crystal Report syntax.
Retrieve a FormulaFieldDefinition object by index or by name through the Item Property of the FormulaFieldDefinitions collection.
Example
This example verifies that a formula field's datasource contains Last Name field from Customer table.
'Declaration
Private Function VerifyFormulaFieldObjectDataSource(ByVal myReportDocument As ReportDocument, ByVal reportObjectName As String) As Boolean
Dim results As Boolean = False
Dim myReportObject As ReportObject = myReportDocument.ReportDefinition.ReportObjects.Item(reportObjectName)
If myReportObject.Kind = ReportObjectKind.FieldObject Then
Dim myFieldObject As FieldObject = myReportObject
Dim myDatabaseFormulaFieldDefinition As FormulaFieldDefinition = myFieldObject.DataSource
results = (myDatabaseFormulaFieldDefinition.Kind = FieldKind.FormulaField) And _
(myDatabaseFormulaFieldDefinition.ValueType = FieldValueType.StringField) And _
(myDatabaseFormulaFieldDefinition.Name = "Last Name") And _
(myDatabaseFormulaFieldDefinition.NumberOfBytes = 16) And _
(myDatabaseFormulaFieldDefinition.FormulaName = "")
End If
VerifyFormulaFieldObjectDataSource = results
End Function
private bool VerifyFormulaFieldObjectDataSource(ReportDocument reportDocument, String reportObjectName)
{
bool results = false;
ReportObject reportObject = reportDocument.ReportDefinition.ReportObjects[reportObjectName];
if (reportObject.Kind == ReportObjectKind.FieldObject)
{
FieldObject fieldObject = (FieldObject)reportObject;
FormulaFieldDefinition databaseFormulaFieldDefinition = (FormulaFieldDefinition)fieldObject.DataSource;
results = ((databaseFormulaFieldDefinition.Kind == FieldKind.FormulaField) &&
(databaseFormulaFieldDefinition.ValueType == FieldValueType.StringField) &&
(databaseFormulaFieldDefinition.Name == "Last Name") &&
(databaseFormulaFieldDefinition.NumberOfBytes == 16) &&
(databaseFormulaFieldDefinition.FormulaName == ""));
}
return results;
}
Inheritance Hierarchy
Object
EngineObjectBase
FieldDefinition
FormulaFieldDefinition
Version Information
Crystal Reports Basic for Visual Studio 2008
Supported since: Crystal Reports for Visual Studio .NET 2002
See Also
Reference
FormulaFieldDefinition Members
CrystalDecisions.CrystalReports.Engine Namespace