RadCalendar for WinForms

RadControls Send comments on this topic.
Getting Started
See Also
Calendar > Getting Started > Getting Started

Glossary Item Box

This tutorial will demonstrate adding selected and special days to the calendar at design time, then iterating and displaying those dates at runtime.

 

  1. In a new Windows Application form drop a RadCalendar control. Set the ThemeName property for the RadCalendar to Office2007Blue and the AllowMultipleSelect property to true.
  2. Drop a RadListBox and RadButton to the form.
  3. In the Properties Window click the ellipses for the SelectedDates property of the RadCalendar.
  4. Click the Add button to append a new selected date to the collection. In the Value property for the date select "Today" from the drop-down calendar.
  5. Add two more selected dates and set the Value properties to the two days following "Today".

  1. In the Properties Window click the ellipses for the SpecialDays property of the RadCalendar.
  2. Click the Add button to append a new RadCalendarDay to the collection.
  3. Set the Date property for the special day to the last day of the month.

  1. Set the Disabled property to true and the Recurring property to DayInMonth.

  1. Double-Click the RadButton in the designer and add the following code to the Click event handler. This code will iterate and list results for the SelectedDates and SpecialDays collections.
[C#] Iterating the SelectedDates and SpecialDates collections Copy Code
private void radButton1_Click(object sender, EventArgs e)
{
 
foreach(DateTime dateTime in radCalendar1.SelectedDates)
 {
   radListBox1.Items.Add(
     
new RadListBoxItem("Selected: " + dateTime.ToShortDateString()));
 }
 
foreach (RadCalendarDay day in radCalendar1.SpecialDays)
 {
   radListBox1.Items.Add(
     
new RadListBoxItem("Special: " + day.Date.ToShortDateString()));
 }
}
[VB] Iterating the SelectedDates and SpecialDates collections Copy Code
Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
 For Each dateTime As DateTime In radCalendar1.SelectedDates
  radListBox1.Items.Add(New RadListBoxItem("Selected: " + dateTime.ToShortDateString()))
 Next
 For Each day As RadCalendarDay In radCalendar1.SpecialDays
  radListBox1.Items.Add(New RadListBoxItem("Special: " + day.[Date].ToShortDateString()))
 Next
End Sub
Run the application. Notice the three selected and the highlighted special day. Use the navigation buttons at the top of the calendar ">" to move to another month.  Because you set the special day Recurring property to DayInMonth, the special day is highlighted in every month.

See Also