NumericFieldFormat Class

Allows you to get and set the numeric format options for any number field in a report.

Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

Syntax

'Declaration
Public Class NumericFieldFormat
    Inherits ReportObjectProperty
    Implements IDisposable
public class NumericFieldFormat : ReportObjectProperty, IDisposable

Example

This example shows how to retrieve the NumericFieldFormat object through the NumericFormat Property of the FieldFormat object and how to initialize the numeric field object.

'Declaration

      Function GetNumericFieldFormat _
         (ByVal reportObjectName As String) As NumericFieldFormat

         Dim field As FieldObject
         Dim numericFormat As NumericFieldFormat

         If TypeOf _
            (Report.ReportDefinition.ReportObjects. _
            Item(reportObjectName)) Is FieldObject Then
            field = _
               Report.ReportDefinition.ReportObjects. _
               Item(reportObjectName)
            Select Case (field.DataSource.ValueType)
               Case FieldValueType.CurrencyField, _
                  FieldValueType.NumberField
                  numericFormat = field.FieldFormat.NumericFormat
                  GetNumericFieldFormat = numericFormat
               Case Else
                  GetNumericFieldFormat = Nothing
            End Select
         Else : GetNumericFieldFormat = Nothing
         End If
      End Function

            Private Sub InitializeNumericFieldObjectFormat(ByVal myReportDocument As ReportDocument, ByVal fieldObjectName As String)
              Dim myReportObject As ReportObject = myReportDocument.ReportDefinition.ReportObjects.Item(fieldObjectName)
              If myReportObject.Kind = ReportObjectKind.FieldObject Then
                Dim myFieldObject As FieldObject = myReportObject

                Dim myNumericFieldFormat As NumericFieldFormat = myFieldObject.FieldFormat.NumericFormat
                myNumericFieldFormat.CurrencySymbolFormat = CurrencySymbolFormat.FixedSymbol
                myNumericFieldFormat.DecimalPlaces = 2
                myNumericFieldFormat.EnableUseLeadingZero = False
                myNumericFieldFormat.NegativeFormat = NegativeFormat.LeadingMinus
                myNumericFieldFormat.RoundingFormat = RoundingFormat.RoundToHundredth
              End If
      End Sub
      
      private NumericFieldFormat GetNumericFieldFormat
         (string reportObjectName)
      {
         FieldObject field;
         NumericFieldFormat numericFormat;
         field =
            Report.ReportDefinition.ReportObjects[reportObjectName]
            as FieldObject;
         if (field != null)
         {
            switch(field.DataSource.ValueType)
            {
               case FieldValueType.CurrencyField:
                  break;
               case FieldValueType.NumberField:
                  numericFormat = field.FieldFormat.NumericFormat;
                  return numericFormat;
                  break;
               default:
                  return null;
                  break;
            }
         }
         else return null;
      }

            private void InitializeNumericFieldObjectFormat(ReportDocument reportDocument, String fieldObjectName)
            {
              ReportObject reportObject = reportDocument.ReportDefinition.ReportObjects[fieldObjectName];
              if (reportObject.Kind == ReportObjectKind.FieldObject)
              {
                FieldObject fieldObject = (FieldObject)reportObject;

                NumericFieldFormat numericFieldFormat = fieldObject.FieldFormat.NumericFormat;
                numericFieldFormat.CurrencySymbolFormat = CurrencySymbolFormat.FixedSymbol;
                numericFieldFormat.DecimalPlaces = 2;
                numericFieldFormat.EnableUseLeadingZero = false;
                numericFieldFormat.NegativeFormat = NegativeFormat.LeadingMinus;
                numericFieldFormat.RoundingFormat = RoundingFormat.RoundToHundredth;
              }
      }
      

Inheritance Hierarchy

Object
   EngineObjectBase
      ReportObjectProperty
         NumericFieldFormat

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

NumericFieldFormat Members
CrystalDecisions.CrystalReports.Engine Namespace