The Masked Textbox Control Visual Studio C#.
Feb6Written by:
2009/02/06 08:16 AM
The TextBox
control is the most used control in a Windows development. A lot of application problems are user related. Most of those are related to invalid input. Controling what and how the user can input data will help in QA as well as program and data flow. Using a masked control will save a lot of time for the developer and reduce the complaints and bugs.
This masked intelligent user control enhances the functionality of the normalTextBox
control. The Mask can be set to any number of types or properties, namely:
- Date
- IP Address
- SSN
- Phone numbers
- digits
- decimal
The textbox control also checks the validation. It also automatically sets the delimiter location.
By default the property Masked is set to None and works like a normal TextBox control. In some builds of Visual Studio 2008 there is a type and spelling mistake. It is spelled 'Maked' as appose to 'Masked'.
If setting the property toDateOnly, the control is masked to Date format.
What the user enters
|
What is Displayed
|
12 |
12/ |
124
|
12/04/
|
13
|
01/3
|
3
|
03/
|
34
|
03/04/
|
14
|
01/04/
|
1/
|
01/
|
You can also experiment with some of the other properties. Example, Phone numbers and decimals are probably the other widely used options. Especially here in South Africa where we have moved over to the 10 digit phone number. Putting a mask on your textbox will enforce your users to enter the correct phone number, including the area dialling codes.
blog comments powered by