# Input Masking

## Content

**True DBGrid for WinForms** provides an [EditMask](/componentone/docs/win/online-truedbgrid/) property that optionally works with the [NumberFormat](/componentone/docs/win/online-truedbgrid/) property to ensure input masking and consistent data entry.

## Specify an Input Mask for Column

The [EditMask](/componentone/docs/win/online-truedbgrid/) property of the [C1DataColumn](/componentone/docs/win/online-truedbgrid/) object is used to specify an input mask template for end-user data entry. The input mask string is composed of special characters that represent either an input character that the user must enter.

The [EditMask](/componentone/docs/win/online-truedbgrid/) must be a string composed of the following symbols:

1. **Wildcards**
<br>
    0 digit
<br>
    9 digit or space
<br>
    \# digit or sign
<br>
    L letter
<br>
    ? letter or space
<br>
    A letter or digit
<br>
    a letter, digit, or space
<br>
    & any character
2. **Localized** **characters**
<br>
    . localized decimal separator
<br>
    , localized thousand separator
<br>
    : localized time separator
<br>
    / localized date separator
3. **Command** **characters**
<br>
    \\ next character is taken as a literal
<br>
    \> translate letters to uppercase
<br>
    < translate letters to lowercase

For example:

```csharp
// Set the mask so the user can enter a phone number, with optional area code, and a state in capitals
this.c1TrueDBGrid1.Columns[0].EditMask = "(###) 000-0000 St\\ate\\: >LL";
```

## Using an Input Mask for Formatting

Whereas the [EditMask](/componentone/docs/win/online-truedbgrid/) property is used to specify an input mask for *data entry*, the [NumberFormat](/componentone/docs/win/online-truedbgrid/) property is used to specify the *display format* of data in a grid cell. If the [NumberFormat](/componentone/docs/win/online-truedbgrid/) property of the column is not specified, the grid simply displays the cached text (stripped of literals) as is; if the [NumberFormat](/componentone/docs/win/online-truedbgrid/) property is specified, the grid sends the cached text to the display formatter.

Since it is common for the input and display formats to be the same, the [NumberFormat](/componentone/docs/win/online-truedbgrid/) property has an *Edit Mask* option. If this option is selected, then the [EditMask](/componentone/docs/win/online-truedbgrid/) property setting will be used for both data input and display. However, the input and display formats need not be the same, so a [NumberFormat](/componentone/docs/win/online-truedbgrid/) option that differs from the [EditMask](/componentone/docs/win/online-truedbgrid/) property can be selected.

Normally, after the user finishes editing a cell in a column which has its [EditMask](/componentone/docs/win/online-truedbgrid/) property set, **True DBGrid for Winforms** caches the modified cell text, but any literal characters in the input mask template will be stripped from the modified cell text beforehand. However, this behavior can be overridden with the [EditMaskUpdate](/componentone/docs/win/online-truedbgrid/) property.

By default, the [EditMaskUpdate](/componentone/docs/win/online-truedbgrid/) property is **False**. This means that when the modified cell text is updated to the database, the grid sends the cached text (stripped of literals), not the formatted text displayed in the cell. Override this default behavior by setting the [EditMaskUpdate](/componentone/docs/win/online-truedbgrid/) property to **True**, which causes the cached text to be formatted according to the [EditMask](/componentone/docs/win/online-truedbgrid/) property before being updated to the database.

Therefore, it is important to set [EditMaskUpdate](/componentone/docs/win/online-truedbgrid/) properly to ensure that the correct data is sent to the database for update.