Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I provide a Mask property to the user for a MaskedTextBox control in a DataGridView column?

I followed the instructions in the article How to: Host Controls in Windows Forms DataGridView Cells in the Visual Studio 2005 Library. I've used this to implement a MaskedTextBox control in a DataGridView. It seems to work but how do I make the "mask" property accessible to the user?

The DataGridView normally does this through a property on the column and the cell. So add a Mask property to the Column and then inside the property set just loop through setting the property on each cell. Alternatively you can create an inheritance model where you get the mask from the OwningColumn inside your cell if a specific mask hasn't been set.