Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
how to make datetimepicker readonly in c# Windows Forms?



Datetime picker is editable in winforms. but i want it t be non-editable mode...
How to do ?

What I have tried:

C#
calVouFromDate.Format = DateTimePickerFormat.Custom;
calVouFromDate.CustomFormat = "dd-MMM-yyyy";
calVouToDate.Format = DateTimePickerFormat.Custom;
calVouToDate.CustomFormat = "dd-MMM-yyyy";
Posted
Updated 3-Mar-16 20:29pm
Comments
HobbyProggy 4-Mar-16 2:21am    
What do you mean by this question?
Do you want it as a Date Display or should the user be able the change the date?
Sathish km 4-Mar-16 4:04am    
ex. if u change the months by up/ down keys. but i don' want this
Sathish km 4-Mar-16 4:05am    
I want the field should be non-editable(read-only)

1 solution

You could set the Enabled property of the control...
C#
private void butDisable_Click(object sender, EventArgs e)
    {
    myDateTimePicker.Enabled = false;
    }

private void butEnable_Click(object sender, EventArgs e)
    {
    myDateTimePicker.Enabled = true;
    }
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 4-Mar-16 2:47am    
5ed; that was quick.
OriginalGriff 4-Mar-16 3:04am    
I fitted an SSD, so VS loads Very Quickly now! :laugh:

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