Share via


TimeFieldFormat Class

Allows you to get and set time format options for any time field in a report.

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

Syntax

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

Remarks

Retrieve the TimeFieldFormat object through the TimeFormat property of the FieldFormat object.

Example

This example returns a TimeFieldFormat object. The code gets the ReportObject by name, and casts it as a FieldObject. If the field is a TimeField, then the method will return a TimeFieldFormat object. This example also shows how to initialize the time field object.

'Declaration

      Function GetTimeFieldFormat _
         (ByVal reportObjectName As String) As TimeFieldFormat

         Dim field As FieldObject
         Dim timeFormat As TimeFieldFormat

         If TypeOf _
            (Report.ReportDefinition.ReportObjects._
            Item(reportObjectName)) Is FieldObject Then
            field = _
               Report.ReportDefinition.ReportObjects._
               Item(reportObjectName)
            If field.DataSource.ValueType = _
               FieldValueType.TimeField Then
               timeFormat = field.FieldFormat.TimeFormat
               GetTimeFieldFormat = timeFormat
           Else : GetTimeFieldFormat = Nothing
           End If
         Else : GetTimeFieldFormat = Nothing
         End If
      End Function

    Private Sub InitializeTimeFieldObjectFormat(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 myTimeFieldFormat As TimeFieldFormat = myFieldObject.FieldFormat.TimeFormat
        myTimeFieldFormat.AMPMFormat = AMPMFormat.AMPMAfter
        myTimeFieldFormat.AMString = "AM"
        myTimeFieldFormat.HourFormat = HourFormat.NumericHour
        myTimeFieldFormat.HourMinuteSeparator = ":"
        myTimeFieldFormat.MinuteFormat = MinuteFormat.NumericMinute
        myTimeFieldFormat.MinuteSecondSeparator = ":"
        myTimeFieldFormat.PMString = "PM"
        myTimeFieldFormat.SecondFormat = SecondFormat.NumericSecond
        myTimeFieldFormat.TimeBase = TimeBase.On24Hour
      End If
    End Sub
      
      private TimeFieldFormat GetTimeFieldFormat
         (string reportObjectName)
      {
         FieldObject field;
         TimeFieldFormat timeFormat;
         field =
            Report.ReportDefinition.ReportObjects[reportObjectName]
            as FieldObject;
         if (field != null)
         {
            if (field.DataSource.ValueType ==
               FieldValueType.TimeField)
            {
               timeFormat = field.FieldFormat.TimeFormat;
               return timeFormat;
            }
            else return null;
         }
         else return null;
      }

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

        TimeFieldFormat timeFieldFormat = fieldObject.FieldFormat.TimeFormat;
        timeFieldFormat.AMPMFormat = AMPMFormat.AMPMAfter;
        timeFieldFormat.AMString = "AM";
        timeFieldFormat.HourFormat = HourFormat.NumericHour;
        timeFieldFormat.HourMinuteSeparator = ":";
        timeFieldFormat.MinuteFormat = MinuteFormat.NumericMinute;
        timeFieldFormat.MinuteSecondSeparator = ":";
        timeFieldFormat.PMString = "PM";
        timeFieldFormat.SecondFormat = SecondFormat.NumericSecond;
        timeFieldFormat.TimeBase = TimeBase.On24Hour;
      }
    }
      

Inheritance Hierarchy

Object
   EngineObjectBase
      ReportObjectProperty
         TimeFieldFormat

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

TimeFieldFormat Members
CrystalDecisions.CrystalReports.Engine Namespace