-
dates and disabling
Hi.
I have 2 datetime pickers, start and end dates
dates will be shown when a user selects a month.
now, when they change the month, I will be getting some datetime values from SQL, depending on the month they choose (or rather for each month they select)
now, these dates from SQL are start and end dates.
What I want is, to disable dates which are stored/returned back to me from SQL, kind of like a booking system.
how can I do this?
so say if in SQL we have this:
dates (2 fields)
16/07/2006 -> 21/07/2006
22/07/2006 -> 13/08/2006
I want the date ranges of these to be disabled in the DTP control when they select the months
is this possible? how?
Thanks!
-
Re: dates and disabling
You can set a minimum and a maximum date for the DTP but you cannot pick and choose blocks of dates that are not allowed. You'd have to add that functionality yourself. You could either handle the ValueChanged event and validate the date chosen or else inherit the DateTimePicker class and add something a little more sophisticated. It would still be a bit messy like that though because you have to let the user enter any numbers because you don't know the actual date they're entering until they're finished, so you'd have to defer validation of manually entered values until then. Selections made by incrementing or decrementing or made from the calendar could be handled more elegantly, but it would still be a hassle.
-
Re: dates and disabling
thanks for that, much appreciated.
hmmm this is gonna be tricky! what other better alternative is there?
-
Re: dates and disabling
You could see what the MonthCalendar offers, plus there may already be third party controls that do what you want. I searched for free calendars a while back and found a few useful ones, although I haven't really played with them so I don't know what their full capabilities are.