Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can anyone tell me how to make a DatTimePicker control in WPF as read-only. That is the user should not be able to enter any value through the key, he can only select through the mouse.

Thanks & Regards,
Ramana
Posted
Updated 10-Mar-11 0:43am
v2
Comments
Michael Bookatz 10-Mar-11 6:52am    
That isn't read only. you mean only enter info by mouse.

Not sure the actual code but you need to handle the keyboard events and make sure that the keyboard events don't do anything

you just need to set focusable property of DatePicker at False in XAML

Focusable="false"
 
Share this answer
 
use this may be your problem solved!

dateTimePicker1.CustomFormat = " ";
C#
dateTimePicker1.Format = DateTimePickerFormat.Custom;
              
               dateTimePicker1.ShowUpDown = true

;
 
Share this answer
 
Date Picker in Wpf can be only Done by mouse
Keyboard is anyways Disabled by Default
 
Share this answer
 
Comments
Ramana Bellary 10-Mar-11 22:40pm    
DatePicker will not accept the text entered through the keyboard,will allow the user to ender some text, which should not be the case.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900