New to Telerik UI for WinForms? Download free 30-day trial

Using Templates

RadCalendar provides a collection of dynamic templates that customize the presentation of calendar days on a "per day" basis. The templates can contain any type of control or simple image and are particularly useful if you want to implement a scheduler-like interface with extra-information, such as images that illustrate events, links to additional sources, etc. This behavior is supported using the RadCalendar SpecialDays collection of RadCalendarDay objects. RadCalendarDay has a TemplateItem property of type RadHostItem that accepts a Control in the constructor.

In the example below a PictureBox control is created and assigned an image from an ImageList. A new instance of RadHostItem is created passing the picture box in its constructor.  Finally we set the TemplateItem property of the special day.  When the day is rendered the associated image is displayed in the cell for that day. The example assumes that you have an instance of ImageList on the form populated with at least one image and at least one special day added to the SpecialDays collection of RadCalendar.

Figure 1: RadCalendar with a picture box added to a cell.

WinForms RadCalendar With a Picture Box Added to a Cell

Assigning a TemplateItem

PictureBox pictureBox = new PictureBox();
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox.Image = imageList1.Images[0];
RadHostItem hostItem = new RadHostItem(pictureBox);
radCalendar1.SpecialDays[0].TemplateItem = hostItem;

Dim pictureBox As New PictureBox()
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
pictureBox.Image = ImageList1.Images(0)
Dim hostItem As New RadHostItem(pictureBox)
RadCalendar1.SpecialDays(0).TemplateItem = hostItem

See Also

In this article