Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Calendar selected date colours

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Resolved [RESOLVED] [2005] Calendar selected date colours

    Hello,
    I'm currently experimenting with the calendar control, and have created a page showing monthly calendars from January 2008, through to January 2009.
    I've done this, rightly or wrongly, by dragging the individual calendar tool from the toolbar onto the page, and have named all 13 of them by their respective month names. I don't know if this is the best way to do this.
    The VisibleDate is always the first of the month so that the correct month is displayed.
    What I want to do then is highlight each public holiday with a given color. To do this, I've created an array of public holidays, and I want to iterate through the array, and highlight the dates accordingly. Iterating through the array is fine, but I don't know how to do it so that it references the correct calendar to work with.
    Next, using some code that I've written in VB.NET, I want to identify two other key dates in each month, and colour those dates with a different colour.
    Any advice or code snippets would be appreciated.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Calendar selected date colours

    You seem to be doing fine so far, although personally I would render all 13 in a loop myself, probably using a repeater control so that I can control how many are rendered. But that's for later.

    Your immediate question is about the holidays. So if you've got your array of public holidays, you must have two 'fields': month and day. Handle your calendar's... rather, handle each calendar's DayRender event. Then check the value of e.Day.Date.

    If e.Day.Date is in your array, then e.Cell.ApplyStyle(), where you pass in the name of a CSS class.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2005] Calendar selected date colours

    Thanks for your reply.
    I was hoping that I'd be able to iterate through the array of holiday dates, and test for conditions like, if the month = 1, then work with Me.January, select the holiday day in January, and apply some colour formatting to that particular day.
    I didn't really want to have to specifically handle 13 events that would be doing pretty much the same thing. It just seems a long-winded way of doing it .... unless I have a go at working with the repeater that you've mentioned.
    Would the repeater be a better way of doing what I want?
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Calendar selected date colours

    You can get one method to handle 13 events. Because you can get the month and date out from the eventargs e, you can compare to the entire array, no problem.


    Yes, a repeater may make things easier as you're putting all your logic in fewer places. You will handle the Repeater's ItemCommand event, assuming the calendar does bubble its DayRender event up! And if it doesn't, you can assign a method to do it, which brings you back to the answer in the previous paragraph.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2005] Calendar selected date colours

    Many thanks for your advice.
    I avoided using the repeater, and using the DayRender event for each calendar event works fine.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [2005] Calendar selected date colours

    Good to know, but eventually you'll learn to use the Repeater

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