Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input mask on C#?

Status
Not open for further replies.

Pumzy

Programmer
Nov 20, 2003
13
JP
Hello peeps! i'd just like to ask how to put input mask on my textbox just like in ms access or just like a masked box in vb... i'd like put "yyyy/MM/dd" as my input mask for a date field.

tnx for anybody who could help...

KDjLogan
 
Depending on your requirements you can do:
1. Check the text typed in using a regular expression and if it doesn't match then clear text and ask user to retype.
2. Display the mask ..../../.. in the text box and override KeyPress, KeyUp, KeyDown in order to manage the characters typed in e.g. accept only digits and fill the . positions one by one by redisplaying the text in the control.
3. More general,more work to do is to derive ,for example, DateTextBox class from the TextBox class and implement it to accept only the text different date format.
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top