Results 1 to 4 of 4

Thread: dates and disabling

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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!

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: dates and disabling

    thanks for that, much appreciated.
    hmmm this is gonna be tricky! what other better alternative is there?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width