Search code examples
c#winforms.net-2.0

How do you set a DateTimePicker to be read only?


I have a DateTimePicker (nullable version) that I need to be read only. I'm not happy with the display if it is disabled, so wanted to know if anyone had a nifty example of how to stop updates on the field?

Thanks.


Solution

  • You could hook the Changed event, and set the value back to your desired value (if different) -- this way you'll cover any cause for change (via mouse, or keyboard)

    Have you considered using a different control, such as a read only textbox or even a label control?