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

    [RESOLVED] Select specific date on calendar

    I want a specific date to be selected on my calendar. MSDN advises to use the property SelectedDate (http://msdn.microsoft.com/en-us/libr...sd(VS.71).aspx) but that isnt recognized in my C# app!

    Code:
    myCalendar.SelectedDate = employee.BirthDate;
    Instead I used this:

    Code:
    myCalendar.TodayDate = employee.BirthDate;
    The problem with this is that it states that TODAYS date is the employees birth date. I however want it to state that the selected day is the employees birth date without the words "today: " infront of it. Is this possible? I tried using the method setDate but I am not too sure how it works...

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

    Re: Select specific date on calendar

    What's wrong with the 'SelectedDate' property? What do you mean when you say "but that isn't recognized in my C#"? Do you get a compilation error? If you don't get a compilation error then what happens? If you don't get a compilation error do you mind posting more of the code where you are setting the 'SelectedDate'? Thanks.

  3. #3
    Join Date
    Jan 2010
    Posts
    130

    Re: Select specific date on calendar

    The dropdown list doesnt contain "SelectedDate" and it is not recognized when I type it manually! I attached a screenshot (sorry, its all in German!).
    Attached Images Attached Images  

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

    Re: Select specific date on calendar

    Good. Now you can answer another question. Is this an ASP.NET application or a Windows application? The MSDN link you had earlier is for the web Calendar...By the look of it you are writing a Windows application so that link doesn't apply...

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

    Re: Select specific date on calendar


  6. #6
    Join Date
    Jan 2010
    Posts
    130

    Re: Select specific date on calendar

    I managed to make SetDate() work using the following code:

    Code:
    calBirthDate.SetDate(lTrainee.BirthDate);
    I still find it strange that SelectedDate isnt accessible from windows.forms!

  7. #7
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    Re: Select specific date on calendar

    Quote Originally Posted by stephsh View Post
    I still find it strange that SelectedDate isnt accessible from windows.forms!
    Although they may be similar, the System.Web.UI.WebControls.Calendar class is not the same as the System.Windows.Forms.MonthCalendar class. This is why they do not have the same properties.
    It's not a bug, it's a feature!

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

    Re: Select specific date on calendar

    Quote Originally Posted by foamy View Post
    Although they may be similar, the System.Web.UI.WebControls.Calendar class is not the same as the System.Windows.Forms.MonthCalendar class. This is why they do not have the same properties.
    That's a good point foamy but I would expect the authors of the library to have a consistency when it comes to common elements. A text box has a Text property whether it is a Windows TextBox or an ASP.net Text Box. Nevertheless the library is what it is so the best thing to do is follow the documentation for the target library

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