Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Masked Input in DataGridView
Message
From
11/09/2008 08:16:03
Vijay Kumar
DNS ERP Pvt Ltd
India
 
 
To
05/09/2008 18:03:40
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01345274
Message ID:
01346551
Views:
7
You want to use a MaskedTextBox in your DataGridViewColumn? Here it is. Add a DataGridViewMaskedTextColumn to your DataGridView and set the Mask string. Then you get a MaskedTextBox using this Mask as EditingControl.

Background

The .NET Framework contains for DataGridView columns a standard TextBox only. By data binding, it's no problem to restrict the input to numbers, e.g. TextBox.CharacterCasing can be set by DataGridView.EditingControlShowing event. More complex restrictions are available in MaskedTextBox. Therefore it's useful to host a MaskedTextBox in a DataGridViewColumn.

Using the Code
The MaskedTextColumn solution consists of three combined classes, added by an attribute class.

The ReferencedDescriptionAttribute class is used in the designer to call an existing description. See details here.

The MaskedText classes are included into your own ExtendedControls.dll assembly, or you store the prepared DLL directly. Add a reference to this assembly, and you can use the DataGridViewMaskedTextColumn. You need to use this class only; the DataGridViewMaskedTextCell class and the DataGridViewMaskedTextControl class are used automatically by the framework itself.

Working by Code
Add a DataGridViewMaskedTextColumn to your DataGridView like any other DataGridViewColumn and set the Mask property
Vijay Kumar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform