Skip to main content

cxFormatController Method

Provides access to the global editor format controller.

Declaration

function cxFormatController: TcxFormatController;

Returns

Type Description
TcxFormatController

The global format controller.

Remarks

Call the cxFormatController function to access the global format controller that allows you to configure currency and date formats for all supported editors in the application project (TcxCustomCurrencyEdit and TcxCustomDateEdit descendant instances).

Available Options

Use the global format controller together with the FormatSettings global variable declared in the standard System.SysUtils unit to configure currency, date, and time formatting settings for all supported DevExpress editors in the application.

Use cxFormatController.StandardDateEditMask and cxFormatController.StandardDateTimeEditMask properties to define date and time input masks. Call the GetFormats procedure to generate date and currency formats based on current locale settings and options accessible through the FormatSettings global variable.

Refer to the TcxFormatController class description for detailed information on all available options.

Code Example

The following code example changes multiple date format settings for all date editors in the application:

uses
  System.SysUtils,  // This unit declares the global FormatSettings variable
  cxFormats,  // This unit declares the global cxFormatController function
  cxDateUtils;  // This unit declares date-related types

  // Define VCL format settings
  FormatSettings.DateSeparator := '-';  // Defines the date separator
  FormatSettings.ShortDateFormat := 'yyyy-MM-dd';  // Defines the short date format
  // Configure the format controller
  cxFormatController.BeginUpdate;  // Initiates the following batch format controller change
  try
    cxFormatController.UseDelphiDateTimeFormats := True;  // Applies the defined VCL format settings
    cxFormatController.StartOfWeek := dMonday;
    cxFormatController.FirstWeekOfYear := fwyFirstFullWeek;
    cxFormatController.GetFormats;  // Generates the required date and currency formats
  finally
    cxFormatController.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
  end;
See Also