keys for each datatype
Is it possible in Windows Forms to constrain input to is data type.
For instance if i want to insert a Date in a Textbox, i be limited to 开发者_StackOverflow社区use only this chars [0-9,/]
Is there a easy and fast way to do this?
Regards
If you're doing something other than a date, use MaskedTextBox
. Do use DateTimePicker
for dates though.
Documentation on the MaskedTextBox.Mask property will tell you how to specify the text you want.
Specifically for dates there is a DateTimePicker control in winforms. With which you can specify a format to limit the characters you want to use to type the date.
For example: dateTimePicker.CustomFormat = "dd/MM/yy";
or dateTimePicker.CustomFormat = "dd-MM-yy";
精彩评论