Telerik UI for WinForms

 

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

calendar-getting-started 004

 

  1. In a new Windows Application form drop a RadCalendar control. Set the AllowMultipleSelect property to true.

  2. Drop a RadListControl 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".

    calendar-getting-started 001
  6. In the Properties Window click the ellipses for the SpecialDays property of the RadCalendar.

  7. Click the Add button to append a new RadCalendarDay to the collection.

  8. Set the Date property for the special day to the last day of the month.

    calendar-getting-started 002
  9. Set the Disabled property to true and the Recurring property to DayInMonth.

    calendar-getting-started 003
  10. 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.

    Copy[C#] Iterating the SelectedDates and SpecialDates collections
    private void radButton1_Click(object sender, EventArgs e)
    {
        foreach (DateTime dateTime in radCalendar1.SelectedDates)
        {
            radListControl1.Items.Add(
              new RadListDataItem("Selected: " + dateTime.ToShortDateString()));
        }
        foreach (RadCalendarDay day in radCalendar1.SpecialDays)
        {
            radListControl1.Items.Add(
              new RadListDataItem("Special: " + day.Date.ToShortDateString()));
        }
    }
    Copy[VB.NET] Iterating the SelectedDates and SpecialDates collections
    Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
        For Each dateTime As DateTime In radCalendar1.SelectedDates
            radListControl1.Items.Add(New RadListDataItem("Selected: " + dateTime.ToShortDateString()))
        Next
        For Each day As RadCalendarDay In radCalendar1.SpecialDays
            radListControl1.Items.Add(New RadListDataItem("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.

RELATED VIDEOS

Using RadCalendar for WinForms

In this video, you'll get an overview of using RadCalendar for WinForms; configuring important properties; using Special Days and Selected Days; styling; responding to Events with style changes. (Runtime: 10:23)

calendar-getting-started 005