Skip to main content
All docs
V23.2

Format a Property Value

  • 3 minutes to read

This lesson explains how to format an entity class property and specify its input mask settings.

The instructions below describe how to customize the display format for the Task.StartDate, Task.DueDate, and Task.PercentCompleted properties.

Note

Before you proceed, take a moment to review the previous lessons:

Step-by-Step Instructions

  1. In the MySolution.Module project, open the Model.DesignedDiffs.xafml file in the Model Editor.
  2. Navigate to the BOModel | MySolution.Module.BusinessObjects | DemoTask | OwnMembers node.
  3. For the DueDate and StartDate child nodes, set the DisplayFormat property value to D (the long date pattern).

    Date-time mask display format

    Note that the EditMask property value is d (the short date pattern).

  4. For the PercentCompleted child node, set the DisplayFormat property to {0:N0}%.

    Percent integer display format

  5. Run the application. Invoke a Detail List for any Task object.

    ASP.NET Core Blazor
    Property editor input masks in ASP.NET Core Blazor
    Windows Forms
    Property editor input masks in Windows Forms

Note how the text format changes when StartDate and DueDate editors receive or lose focus. If you focus an editor, its EditMask property takes effect (the d value corresponding to the short date pattern). If the editor loses focus, its DisplayFormat property has priority (the D value corresponding to the long date pattern).

The value displayed in the Percent Completed property editor includes the percentage sign (‘%’).

Global Default Format

In ASP.NET Core Blazor and Windows Forms applications, you can specify the default format for all properties of one type, for example, System.Decimal or System.DateTime.

Open the Application Model of a platform-specific project, navigate to the corresponding child node of the ViewItems | Property Editors node, and specify the IModelRegisteredPropertyEditor.DefaultDisplayFormat property value.

Global Default Edit Mask

In ASP.NET Core Blazor applications, you can specify the default edit mask for all properties of one type.

Open the Application Model of a platform-specific project and navigate to the corresponding child node of the ViewItems | Property Editors node. Specify the IModelRegisteredPropertyEditor.DefaultEditMask property value.

You can localize the IModelRegisteredPropertyEditor.DefaultDisplayFormat and IModelRegisteredPropertyEditor.DefaultEditMask properties. Note that the values you specify for them in localization resources override the corresponding values from satellite assemblies in any culture except “en-US”.

Note

In .NET 5, the libraries used for globalization functionality have been changed. Refer to the following topic for details: Globalization APIs use ICU libraries on Windows.

If a current thread’s culture is set to a culture that includes only the language and not the country (for example, “de” or “en”), the currency symbol renders as an international currency symbol (¤), for example: 100.00 ¤.

Refer to the following topics for details:

Next Lesson

Localize UI Elements