ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage properties / Properties associated with windows, pages and controls
  • Numeric controls (except for the currency controls)
  • Currency controls
  • Currency + Euro controls
  • Date controls
  • Time controls
  • DateTime controls
  • Duration controls
  • Type of display mask
  • Regular expressions in the display masks
  • Limitations
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The DisplayMask property is used to:
  • Find out the display mask.
  • Modify the display mask.
This display mask is displayed when the control is in read-only or when the control does not have focus.
The DisplayMask property is applied:
  • Numeric, Currency, Date, Time and Duration edit controls.
  • Numeric, Currency, Date, Time and Duration columns of a Table control.
  • WINDEVWindows to editable or non-editable Combo Box controls.
  • WINDEVWindows columns of a Table control displayed by Combo Box controls.
AndroidiPhone/iPadIOS Widget Note: This property is available for Table field columns in Android and iPhone/iPad applications.
Example
EDT_DATE.InputMask = "DD/MM/YYYY"
SAI_DATE.DisplayMask = "DDD, D MMMM AAA" // ex: "Tuesday, March 3, 2011".
WINDEVWindows
// Modify the mask of a column in a Table control displayed by a Combo Box
COMBO_TableInput.COL_DateCol.DisplayMask = "DDD, the D MMMM YYY"
Syntax

Finding out the display mask of a control Hide the details

<Result> = <Control used>.DisplayMask
<Result>: Constant or character string
Display mask of the specified control. The display mask depends on the type of control. For more details, see the remarks.
<Control used>: Control name
Name of the control to be used.

Modifying the display mask of a control Hide the details

<Control used>.DisplayMask = <New display mask>
<Control used>: Control name
Name of the control to be used.
<New display mask>: Constant or character string
New display mask for the specified control. The display mask depends on the type of control. For more details, see the remarks.
If this parameter corresponds to an empty string (""), the display mask will be identical to the input mask defined for the control.
Remarks

Numeric controls (except for the currency controls)

Three types of masks are available:
  1. Preset display masks
  2. Custom display masks
  3. Special custom display masks
1. Preset display masks
maskBitcoinNumeric input mask used for Bitcoins. The Bitcoin symbol is displayed.
WINDEV Mobile This constant is not available.
maskFileSizeNumeric mask for file and disk sizes.
Note: The unit change (e.g. from KB to MB) is performed for each multiple of 1024.. Therefore, the mask may display 1003 KB.
maskScientificNumeric input mask for scientific notation.
WINDEV Mobile This constant is not available.
maskSystemNumeralNumeric mask used by the system.
Corresponds to the mask defined in the system regional settings ("Regional options" in the control panel).

Examples:
// File size mask
EDT_Edit1.DisplayMask = maskFileSize
EDT_Edit1 = 5681234 // Displays 5.68 MB
// Bitcoin mask
EDT_Edit2.DisplayMask = maskBitcoin
EDT_Edit2 = 5681234 // Displays 0.05 681 234 B
// Scientific mask
EDT_Edit3.DisplayMask = maskScientific
EDT_Edit3 = 5681234 // Displays 5.681234E+06
2. Custom display masks
Display masks are defined using the following characters: "9", ".", ",", "+" and "-", "$" and spaces.
For example: "99.999,99".
The display masks take into account the decimal separator, the thousand separator and the currency symbol defined for the language.
In the code (regardless of the language):
  • " " (space) is replaced with the thousand separator
  • "," (comma) is replaced with the decimal separator
  • "$" is replaced with the currency symbol (write "$$" to avoid this substitution)
3. Special custom display masks
  • Using the % symbol:
    The value assigned through programming to the control is multiplied by 100 and the "%" symbol is displayed.
    You can write "%%" to display the % character without multiplying the value by 100.
    Example: Assigning a value to the control programmatically
    EDT_Edit1.DisplayMask = "999,9%"
    EDT_Edit1 = 0.562 // Displays 56.2 %
     
    EDT_Edit1.DisplayMask = "999,9%%"
    EDT_Edit1 = 0.562 // Displays 0,6 %
  • Use of parentheses: display of negative numbers.
    Example:
    EDT_Edit1.DisplayMask = "(999 999)"
    EDT_Edit1 = -1234      // Displays (1 234)
    EDT_Edit1 = 1234       // Displays 1 234
  • Use of the - sign at the end of the string: display of negative numbers (it is possible to write "--" to display the - sign at the end of the string)
    Example:
    EDT_Edit1.DisplayMask = "999 999 -"
    EDT_Edit1 = -1234      // Displays 1 234-
  • Multiple display mask: display mask to define positive format, negative format, value if 0 is used, value if NULL is used.. The following syntax is used:
    <Format of positive numbers>;<Format of negative numbers>;<Value if 0>;<Value if NULL>
    Example:
    EDT_Edit1.DisplayMask = "999 999;-999 999;0;<NULL>"
    EDT_Edit1 = -1234      // Displays - 1 234

    Note: You can specify a color by using [<Couleur>] next to the desired mask.. <Color> can correspond to:
    • to one of the following constants: Red, Green, Blue, Black, White, Yellow, Orange
    • a hexadecimal value in "#BBGGRR" format.
    Example:
    EDT_Edit1.DisplayMask = "999 999;-999 999[Red];0;<NULL>"
    EDT_Edit1 = -1234      // Displays - 1 234 in red
     
    EDT_Edit1.DisplayMask = "999 999;-999 999[#FF0000];0;<NULL>"
    EDT_Edit1 = -1234      // Displays - 1 234 in blue

    Note: The color specified in the display mask takes precedence over the Color property.. It is ignored if the control is grayed.
Remarks:
  • If you want to pad the number with zeros on the left, use "0" on the left of the mask. For example: "099.999.99".
  • If you want to pad the decimal part of the number to with zeros, use "9" to the right of the decimal point. For example, when using the "9999,99000" mask, the number 12 is displayed as "12,00" and not as "12,00000".
    On the other hand, the number "12.368" is correctly displayed: its value is preserved, without being truncated or rounded.
  • To force the signs, use the "+" character on the left. For example: "+9999".

Currency controls

The display masks and the numeric masks have the same type. The difference lies in precision: the monetary units have 17 significant digits for the integer part and a maximum of 6 decimal places.
For example: "99 999 999 999 999,999999".
Note: A predefined mask can also be used for Monetary type fields:
maskSystemCurrencyCurrency mask used by the system. Corresponds to the mask defined in the system regional settings ("Regional options" in the control panel).

Currency + Euro controls

The display masks and the currency masks have the same type. The dollar character ("$") can be added into the mask to display the current currency.
For example: "$999.99" will display "250.25 E" if the current currency is the Euro.

Date controls

The display masks for the Date controls are:
  • a custom mask:
    • "DD/MM/YYYY"
    • "DD/MM/YY"
    • "DDD DD"
    • "MM/DD/YYYY"
    • "MM/DD/YY"
    • "YYYY/MM/DD"
    • "YY/MM/DD"
    • "DD/MM/YYYY HH:MM:SS"
    • "MM/DD/YYYY HH:mm:SS"
    • "DD/MM/YYYY HH:mm:SS:CCC"
    • "MM/DD/YYYY HH:mm:SS:CCC"
    • "DDDD DD MMMM YYYY"
    • "Dddd DD Mmmm YYYY"
    • "Dddd DD Mmm YYYY"
A custom mask can be built from the following elements:
  • "DD" (corresponding to the day of the week in figures, e.g. 12)
  • "DDDD" (corresponding day of the week, e.g. "Thursday"). The case used depends on the language options of the project.
  • "DDDD" (corresponding to the day of the week with the first letter capitalized, e.g. Monday)
  • "dddd" (corresponding to the day of the week with the first letter forced into lower case, e.g. Monday)
  • "DDD" (abbreviation for the day of the week, "Thu" for example). The case used depends on the language options of the project.
  • "DDD" (abbreviation for the day of the week with the first letter capitalized, e.g.: Mon)
  • "ddd" (abbreviation for the day of the week with the first letter forced into lower case, e.g.: mon)
  • "MM" (month in figures, e.g. 12)
  • "MMMM" (non-abbreviated month, for example "January"). The case used depends on the language options of the project.
  • "Mmmm" (month spelled out with the first letter capitalized, e.g. January)
  • "mmmm" (month in all letters with the first letter forced into lower case, e.g. January)
  • "MMM" (abbreviation of the month, "Jan" for example). The case used depends on the language options of the project.
  • "Mmm" (month abbreviation with the first letter capitalized, e.g. Jan)
  • "mmm" (month abbreviation with the first letter forced into lower case, e.g. jan)
  • "YYYY" (year on four digits, "2001" for example)
  • "YY" (last two digits of the year, "01" for example)
  • a constant corresponding to a preset mask:
    maskDateEmailThe format used corresponds to the date format of the RFC-5322 standard used to encrypt an email, an RSS feed, etc, ...
    The result is expressed in the local time zone.
    AndroidJava Not available.
    maskDateEmailUTCThe format used corresponds to the date format of the RFC-5322 standard used to encrypt an email, an RSS feed, etc, ...
    The result is expressed in universal time (UTC).
    AndroidJava Not available.
    maskDateInternetThe format used corresponds to the date format of the RFC-3339 standard used for international communications.
    The result is expressed in the local time zone.
    maskDateInternetUTCThe format used corresponds to the date format of the RFC-3339 standard used for international communications.
    The result is expressed in universal time (UTC).
    maskDateRelativeDurationMask used to express the time elapsed (or that will elapse) between today's date and the specified date. This mask is expressed in natural language. The different formulations used can be configured in the project description for the current language:
    1. On the "Project" tab, in the "Project" group, click "Description".
    2. In the "Languages" tab:
      • select the language to configure.
      • select the "Date" tab.
    3. Click the "Dates and Times in natural language" button.
    4. Define (if necessary) the custom captions to use. These captions will be used:
      • for the result of DateToString.
      • for the controls that use the "Relative duration" display mask.
    maskDateSystem
    System mask defined in the project description for the current language:
    1. On the "Project" tab, in the "Project" group, click "Description".
    2. Select the "Languages" tab then the "Date" tab.
    3. The format used corresponds to:
      • the settings of the operating system,
      • the specified parameters (with the defined days and months).
These masks can be combined. For example: "On DD DD Mmmm YYYY at HH:mm" will give a result of the form "On Thu Feb 01 1979 at 21:35".

Time controls

The display masks for the Time controls are:
  • "HH:MM"
  • "HH h MM"
  • "HH:MM:SS"
  • "HH:MM:SS AM": Used to manage time in AM/PM format.
  • "HH:MM:SS:CC"
  • The preset mask corresponds to the system time. The system time depends on the mask selected in the regional system setings ("Regional options" in the control panel).
    maskSystemTimeMask used by the system for the time.

DateTime controls

To specify a DateTime display mask, you must:
  1. Change the type of the control (or table column) to Date ("Details" tab in the description window of the control or column).
  2. Change the display mask of this control or column ("Details" tab in the control or column description window, or DisplayMask property).

Duration controls

The following elements can be used to define a custom mask (case sensitive). To present the custom masks, let's take a duration equal to 0 day 04 hours 15 minutes 03 seconds and 412 thousandths of a second:
  • +1: only the most significant unit is displayed (in our example, only the number of hours).
  • +2: only the two most significant units will be displayed (in our example, only the number of hours and the number of minutes)..
    Specify '+3' or '+4' to display the three or four most significant units.
  • J: the number of days will be displayed if this number is greater than 0 (in our example, the number of days will not be displayed).
  • H: the number of hours will be displayed if this number or the number of days is greater than 0.. If this number contains a single digit, this digit will be displayed (the number of hours will be '4' in our example).
  • HH: the number of hours will be displayed if this number or the number of days is greater than 0.. If this number contains a single digit, this digit will be preceded by '0' (the number of hours will be '04' in our example).
  • M: the number of minutes will be displayed if this number or the number of a longer duration (number of days or hours) is greater than 0.. If this number contains a single digit, this digit will be displayed (the number of minutes will be '15' in our example).
  • MM: the number of minutes will be displayed if this number or the number of a longer duration (number of days or hours) is greater than 0.. If this number contains a single digit, this digit will be preceded by '0' (the number of minutes will be '15' in our example).
  • S: the number of seconds will be displayed if this number or a longer number (days, hours or minutes) is greater than 0.. If this number contains a single digit, this digit will be displayed (the number of seconds will be '3' in our example).
  • SS: the number of seconds will be displayed if this number or a longer number (days, hours or minutes) is greater than 0.. If this number contains a single digit, this digit will be preceded by '0' (the number of seconds will be '03' in our example).
  • CC: the number of hundredths of a second will be displayed (in our example, the number of hundredths of a second will be '41').
  • CCC: the number of thousandths of a second will be displayed (in our example, the number of thousandths of a second will be '412').
Remarks:
  • If the separator corresponds to the ":" character, the letter corresponding to the most significant unit will be added ('h' for hour, 'm' for minute, 's' for second, 'cs' for hundredths of a second and 'ms' for thousands of a second).
  • To display a duration in an Edit control in hours/minutes format (instead of days/hours/minutes), it is necessary to define a mask of the type: "+5 HHhMMm", where "+5" designates the number of digits to be displayed for the hours..

Type of display mask

A mask can be replaced with a mask of the same type. For example, the display mask of a DATE control cannot be replaced with the display mask of a TIME control.
Assigning an incorrect display mask will trigger an error message.

Regular expressions in the display masks

The regular expressions used in this property must not be the ones used in MatchRegularExpression.
In display masks, regular expressions prevent certain characters or sequences of characters from being displayed.
In MatchRegularExpression, regular expressions are used to check the string format.
Example: Checking whether the T1 string contains a letter and a digit:
  • with the MatchRegularExpression function: the regular expression used is [A-Za-z][0-9]
  • with property DisplayMask: the regular expression used is [A-Za-z]{0,1}[0-9]{0,1}

Limitations

In a window, the DisplayMask property applies only to:
  • Numeric, Currency, Date, Time and Duration edit controls,
  • Numeric, Currency, Date, Time and Duration columns of a Table control,
  • groups of edit controls,
  • WINDEVWindows editable or non-editable Combo Box controls.
  • WINDEVWindows columns of a Table control displayed by Combo Box controls.
The DisplayMask property does not apply to controls in a report.
Minimum version required
  • Version 17
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/30/2024

Send a report | Local help