Skip to main content Skip to footer

Displaying Images on Holiday dates in C1Calendar

C1Calendar for Winforms is a fully functional Outlook-style calendar that enables end-users to select the current date or the set of dates to navigate through the C1Schedule control. Depending on the amount of space available, C1Calendar control can display one or more months at a time. This blog demonstrates how one can customize the appearance of the C1Calendar control to display Images for the Holiday dates in the Calendar. For doing this, we'll make use of the C1.Win.C1Schedule.UI.CalendarTheme Class. This Theme class represents the theme for the C1Calendar control. It is a set of Style objects which contain display attributes that determine the appearance of the control. Adding Holidays in the Calendar



private void Form1_Load(object sender, EventArgs e)  

{  
           // Add Holidays in the C1Calendar object  
           c1Calendar1.CalendarInfo.Holidays.AddRange(  
                     new DateTime[] {new DateTime(2012,01,26),  
                     new DateTime(2013,03,08),  
                     new DateTime(2013,04,06),  
                     new DateTime(2013,08,15),  
                     new DateTime(2013,08,20),  
                     new DateTime(2013,10,24),  
                     new DateTime(2012,11,13),  
                     new DateTime(2012,11,15),  
                     new DateTime(2012,11,28),  
                     new DateTime(2012,12,25)});  
}  


Adding Images on the Holiday Dates



private void c1Calendar1_Paint(object sender, PaintEventArgs e)  

{  
         CalendarTheme t = c1Calendar1.Theme;  
         // Assign the Holidays Collection to the Bolded Dates array in the Calendar  
         c1Calendar1.BoldedDates = c1Calendar1.CalendarInfo.Holidays.ToArray<DateTime>();  
         // Add Background Image to the Bolded Dates Theme in the Calendar Themes  
         t[7].BackImage = new Bitmap("../../Resources/Flag\_of\_India.svg.png");  
}  


Final output looks as follows : Refer to the attached samples for complete implementation : Download Sample CS Download Sample VB

MESCIUS inc.

comments powered by Disqus