vcl-cxformats-54e24f36.md
Provides access to the global editor format controller.
function cxFormatController: TcxFormatController;
| Type | Description |
|---|---|
| TcxFormatController |
The global format controller.
|
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).
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.
The following code example changes multiple date format settings for all date editors in the application:
uses
System.SysUtils, // Declares the global FormatSettings variable
cxFormats, // Declares the global cxFormatController function
cxDateUtils; // 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;
#include "System.SysUtils.hpp" // Declares the global FormatSettings variable
#include "cxFormats.hpp" // Declares the global cxFormatController function
#include "cxDateUtils.hpp" // 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 defined VCL format settings
cxFormatController()->StartOfWeek = dMonday;
cxFormatController()->FirstWeekOfYear = fwyFirstFullWeek;
cxFormatController()->GetFormats(); // Generates required date and currency formats
}
__finally
{
cxFormatController()->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
See Also