|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calendar control questionIs it possible to highlight more than one date in the calendar control? I'm
trying to display a calendar to the user and highlight the dates that have action items. Is this possible? Or is this control just for selecting dates? "DougS" <doug@nospam.com> wrote in message You need to investigate the DayRender event, which fires once per day news:4wcrf.2524$Or5.684@tornado.southeast.rr.com... > Is it possible to highlight more than one date in the calendar control? > I'm trying to display a calendar to the user and highlight the dates that > have action items. Is this possible? Or is this control just for selecting > dates? displayed in the calendar control's current view. You work out which day it is by the Day property of the DayRenderEventArgs parameter. E.g. I maintain an online calendar for several bands, showing dates of rehearsals, gigs etc. First I query SQL Server for any "events" which fall between the beginning and end dates of the calendar's current view and read them into an ArrayList. Then it's a simple matter to highlight any day on which the band has an "event", as follows: public void DayRender(object source, DayRenderEventArgs e) { if (arrDates.ContainsKey(e.Day.Date.ToString("dd MMM yyyy")) && !e.Day.IsOtherMonth) { Array arrStyle = arrDates[e.Day.Date.ToString("dd MMM yyyy")].ToString().Split((Convert.ToChar(";"))); e.Cell.Font.Bold = true; e.Cell.ForeColor = System.Drawing.Color.FromName(arrStyle.GetValue(0).ToString()); e.Cell.BackColor = System.Drawing.Color.FromName(arrStyle.GetValue(1).ToString()); } } |
|||||||||||||||||||||||