CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2010
    Posts
    130

    [RESOLVED] Save SetDate

    I display a calendar in my windows form with a particular date highlighted on it:

    Code:
    calBirthDate.SetDate(lTrainee.BirthDate);
    The user then has the possibility to manually change this highlighted date. On saving I want this newly highlighted date to be saved. How do you set the date for setDate()? I tried the following but it didnt work:

    Code:
    lTrainee.BirthDate = (DateTime)calBirthDate.SetDate.Value;

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Save SetDate

    Quote Originally Posted by stephsh
    I tried the following but it didnt work...
    1. Do you get a build error?
    2. Do you get a run-time error?
    3. Have you checked the value of the calBirthDate.SetDate property at run-time?

  3. #3
    Join Date
    Jan 2010
    Posts
    130

    Re: Save SetDate

    I received a build error so I didnt try to debug it. The first setDate() methods works fine

  4. #4
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Save SetDate

    I assume you're using the MonthCalendar control. Seems like a funny control. Have a loot at this link MonthCalendar.SelectionRange...

  5. #5
    Join Date
    Jan 2010
    Posts
    130

    Re: Save SetDate

    Thanks, that helped! I kept looking at the code on the MSDN library for setDate() but didnt read the remark that this is just assigning the same value to both selectedRangeStart and selectedRangeEnd. I should therefore be able to use the following code:

    Code:
    lTrainee.BirthDate = (DateTime) calBirthDate.SelectionRange.End;

  6. #6
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: [RESOLVED] Save SetDate

    Even neater...

    Code:
    // Form Initialisation
    clBirthDate.MaxSelectionCount = 1;
    
    // Event DateSelected
    lTrainee.BirthDate = calBirthDate.SelectionStart;
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  7. #7
    Join Date
    Jan 2010
    Posts
    130

    Re: [RESOLVED] Save SetDate

    Thank you, it works perfectly!

Tags for this Thread

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

Featured