windowsforms-devexpress-dot-xtraeditors-dot-mask-dot-maskproperties-bcda29b0.md
Gets or sets whether to use mask settings to format the editor’s display text when the editor is not focused.
Namespace : DevExpress.XtraEditors.Mask
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool UseMaskAsDisplayFormat { get; set; }
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Overridable Property UseMaskAsDisplayFormat As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true to use mask settings to format the editor’s display text when the editor is not focused; false to use formatting settings specified by the DisplayFormat property.
|
Enable the UseMaskAsDisplayFormat property to apply mask settings to the editor’s display text (when the editor is not focused). As a result the editor’s text in edit and display mode will be identical.
The following example creates a DateTime editor to display/edit values in the ‘OrderDate’ grid column. The editor uses mask settings to format its value in edit and display modes:
using System;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors.Repository;
namespace DXApplication {
public partial class Form1 : RibbonForm {
RepositoryItemDateEdit dateEditor;
public Form1() {
InitializeComponent();
// Forcibly initialize the DevExpress GridControl.
gridControl1.ForceInitialize();
// Create and initialize a repository item (cell editor) to edit DateTime values.
dateEditor = new RepositoryItemDateEdit() {
Name = "orderDateEditor",
EditMask = "D",
UseMaskAsDisplayFormat = true
};
// Add the repository item to the grid's RepositoryItems collection.
gridControl1.RepositoryItems.Add(dateEditor);
// Assign the repository item to the 'OrderDate' column.
gridView1.Columns["OrderDate"].ColumnEdit = dateEditor;
}
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraEditors.Repository
Namespace DXApplication
Partial Public Class Form1
Inherits RibbonForm
Private dateEditor As RepositoryItemDateEdit
Public Sub New()
InitializeComponent()
' Forcibly initialize the DevExpress GridControl.
gridControl1.ForceInitialize()
' Create and initialize a repository item (cell editor) to edit DateTime values.
dateEditor = New RepositoryItemDateEdit() With {
.Name = "orderDateEditor",
.EditMask = "D",
.UseMaskAsDisplayFormat = True
}
' Add the repository item to the grid's RepositoryItems collection.
gridControl1.RepositoryItems.Add(dateEditor)
' Assign the repository item to the 'OrderDate' column.
gridView1.Columns("OrderDate").ColumnEdit = dateEditor
End Sub
End Class
End Namespace
The following image shows the result:
If the UseMaskAsDisplayFormat property is set to false , the editor’s display text is formatted based on settings specified by the DisplayFormat property.
Note
Setting the UseMaskAsDisplayFormat property has no effect if the editor’s MaskProperties.MaskType property is set to MaskType.None.
Read the following topic for additional information: Input Mask.
The following code snippets (auto-collected from DevExpress Examples) contain references to the UseMaskAsDisplayFormat property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-mvvm-best-practices/CS/POCODependencies/SimpleDependenciesUserControl.cs#L21
editor1.Properties.Mask.EditMask = "n0";
editor1.Properties.Mask.UseMaskAsDisplayFormat = true;
// Apply a mask to the created editor.
dateRepositoryItem.Mask.UseMaskAsDisplayFormat = true;
dateRepositoryItem.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
winforms-mvvm-best-practices/VB/POCODependencies/SimpleDependenciesUserControl.vb#L21
editor1.Properties.Mask.EditMask = "n0"
editor1.Properties.Mask.UseMaskAsDisplayFormat = True
' Apply a mask to the created editor.
dateRepositoryItem.Mask.UseMaskAsDisplayFormat = True
dateRepositoryItem.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime
See Also