Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My project is in windows application. I used payroll system for employees. So I create holiday master for holidays. I want to display the holidays with month calendar. For example If the specify day is holiday , it displays with reason of the holiday in month calendar. I already creating to webapplication used with calendar control. But I didn't know how to do it with windows application.
So pls help me....
Thanks in advance..
Posted

1 solution

Well, in a windows forms application, the month calender doesn't support descriptions, but there are alternatives. Here's a code example.

Add this class to your project.
C#
using System;
public class Holiday
{
    public DateTime Time {get; set;}
    public string Description {get; set;}
    public Holiday(DateTime time, string des)
    {
        Time = time;
        Description = des;
    }
}

Then use the following code in your code block.
C#
Holiday[] holidays = { new Holiday(new DateTime(2012, 12, 25), "Christmas"), new Holiday(new DateTime(2013, 1, 1), "New year's") };
monthCalendar1.DateSelected += delegate(object sender, DateRangeEventArgs e)
{
    Holiday day = holidays.ToList().Find(t => t.Time == e.Start);
    if (day != null)
    {
         //Do something here...display messagebox, etc
    }
};

foreach (Holiday time in holidays) //Bold holidays
    monthCalendar1.AddBoldedDate(time.Time);
 
Share this answer
 
v3
Comments
devausha 17-Jan-13 0:38am    
Where I use this code. In the form_load event? I didn't unterstand,
"monthCalendar1.DateSelected += delegate(object sender, DateRangeEventArgs e)"
is event or code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900