Click here to Skip to main content
15,887,344 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm working on C# windows form app and I have a two dateTimePicker controls. I've used customFormat to display the controls in "HH:mm:ss". I'd like to use one control as my startTime and the other as my endTime. I can't seem to figure out how to set a maximum time and a minimum times for the controls or how not allow the dateTimePicker thats used for startTime to greater then the dateTimePicker thats used for my endTime. Example

// would like for time to be within a specified range
// e.g. 09:30:00 to 16:00:00
DateTimePicker dtpStartTime = new DateTimePicker();
dtpStartTime.ShowUpDown = true;
dtpStartTime.Format = DateTimePickerFormat.Custom;
dtpStartTime.CustomFormat = "HH:mm:ss";

// would like to time to be within a specified range
// e.g. 09:30:00 to 16:00:00
DateTimePicker dtpEndTime = new DateTimePicker();
dtpEndTime.ShowUpDown = true;
dtpEndTime.Format = DateTimePickerFormat.Custom;
dtpEndTime.CustomFormat = "HH:mm:ss";
Posted

1 solution

Work with the MinDate and MaxDate Properties (Type is DateTime).
 
Share this answer
 

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