开发者

keys for each datatype

开发者 https://www.devze.com 2023-01-24 15:27 出处:网络
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 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";

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号