Limiting the dates within a C# win form DateTimePicker

前端 未结 5 1372
悲&欢浪女
悲&欢浪女 2020-12-11 22:33

Is it possible to limit which dates a user can select from a dateTimePicker on a C# winforms application?

The basic principle for me is this: I have a <

5条回答
  •  鱼传尺愫
    2020-12-11 23:11

    The DateTimePicker control has MaxDate and MinDate properties. Set those, and you can control the range of dates that can be selected. Currently on my Windows XP with Windows Classic theme the unselectable dates do not appear grayed, but this may vary depending on operating system, theme, etc. If you absolutely must gray them, then you will have to subclass the DateTimePicker control and do the (or part of the) painting yourself.

提交回复
热议问题