# DataGridViewMaskedTextBoxCell

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [DataGridViewElement](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewelement.md)
  * [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md)
    * [DataGridViewMaskedTextBoxCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewmaskedtextboxcell.md)

Displays an editable [MaskedTextBox](/api/wisej.web/editors/maskedtextbox.md) control in a [DataGridViewCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md) cell when in edit mode.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DataGridViewMaskedTextBoxCell : DataGridViewCell
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DataGridViewMaskedTextBoxCell
    Inherits DataGridViewCell
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) DataGridViewMaskedTextBoxCell()

Initializes a new instance of [DataGridViewMaskedTextBoxCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewmaskedtextboxcell.md).

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) Culture

[CultureInfo](https://docs.microsoft.com/dotnet/api/system.globalization.cultureinfo): Returns or sets the culture information associated with the masked cell.

### ![](/files/hsR4ok3152WyAf8J2C1u) EditType

[Type](https://docs.microsoft.com/dotnet/api/system.type): Returns the type of the cell's editing control.

### ![](/files/hsR4ok3152WyAf8J2C1u) Mask

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the input mask. (Default: `""`)

The [Mask](#mask) is a string that defines the masking characters and the literals to display and process during user input and when reading the [Value](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcell.md#value) property.\
Server side masking is processed by an instance of the [MaskedTextProvider](https://docs.microsoft.com/dotnet/api/system.componentmodel.maskedtextprovider) class exposed by the [MaskedTextProvider](#maskedtextprovider) property. On the client side, the mask processing is performed by the "wisej.utils.MaskProvider.js" class while the user edits the input field.

| Masking Character | Description                                                                                                                                                                                   |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0                 | Digit, required. This element will accept any single digit between 0 and 9.                                                                                                                   |
| 9                 | Digit or space, optional.                                                                                                                                                                     |
| #                 | Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the Text property. Plus (+) and minus (-) signs are allowed.                               |
| L                 | Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to \[a-zA-Z] in regular expressions.                                                      |
| ?                 | Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to \[a-zA-Z]? in regular expressions.                                                     |
| &                 | Character, required. This element behaves like the "L" element.                                                                                                                               |
| C                 | Character, optional. Any non-control character. This element behaves like the "?" element.                                                                                                    |
| A                 | Alphanumeric, required. The only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "a" element.                                                 |
| a                 | Alphanumeric, optional. The only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "A" element.                                                 |
| .                 | Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's FormatProvider property.                 |
| ,                 | Thousands placeholder. The actual display character used will be the thousands placeholder appropriate to the format provider, as determined by the control's FormatProvider property.        |
| :                 | Time separator. The actual display character used will be the time symbol appropriate to the format provider, as determined by the control's FormatProvider property.                         |
| /                 | Date separator. The actual display character used will be the date symbol appropriate to the format provider, as determined by the control's FormatProvider property.                         |
| $                 | Currency symbol. The actual character displayed will be the currency symbol appropriate to the format provider, as determined by the control's FormatProvider property.                       |
| <                 | Shift down. Converts all characters that follow to lowercase.                                                                                                                                 |
| >                 | Shift up. Converts all characters that follow to uppercase.                                                                                                                                   |
|                   |                                                                                                                                                                                               |
| \\                | Escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash.                                                                                     |
| Others            | Literals. All non-mask elements will appear as themselves within MaskedTextBox. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user. |

If you change the [Mask](#mask) when the control already contains a value, it will apply the new mask to the existing text.\
The decimal (.), thousand (,), time (:), date (/), and currency ($) symbols default to displaying those symbols as defined by the application's culture. You can force a specific [DataGridViewMaskedTextBoxCell](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewmaskedtextboxcell.md) them to display symbols for another culture by using the [Culture](#culture) property. Otherwise you can set the application-wide culture by setting the [CurrentCulture](/api/wisej.web/general/application.md#currentculture) property.

### ![](/files/hsR4ok3152WyAf8J2C1u) MaxInputLength

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns or sets the maximum number of characters that can be entered into the text box. (Default: `0`)

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception)\
  The value is less than 0.

### ![](/files/hsR4ok3152WyAf8J2C1u) PromptChar

[Char](https://docs.microsoft.com/dotnet/api/system.char): Returns or sets the character used to represent the absence of user input in [MaskedTextBox](/api/wisej.web/editors/maskedtextbox.md). (Default: `_`)

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception)\
  The character specified when setting this property is not a valid prompt character, as determined by the [IsValidPasswordChar](https://docs.microsoft.com/dotnet/api/system.componentmodel.maskedtextprovider.isvalidpasswordchar\(system.char\)) method of the [MaskedTextProvider](https://docs.microsoft.com/dotnet/api/system.componentmodel.maskedtextprovider) class.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  The prompt character specified is the same as the current password character, [PasswordChar](/api/wisej.web/editors/maskedtextbox.md#passwordchar). The two are required to be different.

### ![](/files/hsR4ok3152WyAf8J2C1u) TextMaskFormat

[MaskFormat](/api/wisej.web/enumerations/wisej.web.maskformat.md): Returns or sets a value that determines whether literals and prompt characters are included in the formatted string. (Default: `IncludeLiterals`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Tools

[ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md): Returns the instance of [ComponentToolCollection](/api/wisej.web/editors/wisej.web.componenttoolcollection.md) associated with this cell.

### ![](/files/hsR4ok3152WyAf8J2C1u) ValueType

[Type](https://docs.microsoft.com/dotnet/api/system.type): Returns or sets the data type of the values in the cell.

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) InitializeEditingControl(editor, style)

Initializes the control used to edit the cell.

| Parameter  | Type                                                                                                    | Description                                                                                                                                                    |
| ---------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **editor** | [Control](/api/wisej.web/general/control.md)                                                            | The [Control](/api/wisej.web/general/control.md) that is used to edit the cell.                                                                                |
| **style**  | [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md) | The [DataGridViewCellStyle](/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellstyle.md) that is in effect for the cell entering edit mode. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)*editor* is null.

### ![](/files/hsR4ok3152WyAf8J2C1u) ShouldUpdate()

Indicates whether the cell data should be updated on the client even if the user didn't change the value when editing.

**Returns:** [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean).

## Implements

| Name                                                                    | Description                                                                                                     |
| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata.md)           | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface. |
| [ICommandSource](/api/wisej.web/interfaces/wisej.web.icommandsource.md) | Defines an object that can invoke a [Command](/api/wisej.web/interfaces/wisej.web.icommandsource.md#command).   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewmaskedtextboxcell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
