Version

Retrieve the Selected Dates

The xamMonthCalendar™ control exposes two properties that you can use to retrieve the date(s) an end user selects. The SelectedDates collection returns a collection of DateTime structures while the SelectedDate property returns a single Nullable DateTime structure. If an end user selects multiple dates, the SelectedDate property will return the first date that the end user selected.

The following example code demonstrates how to retrieve the selected dates by iterating over the SelectedDates collection.

In Visual Basic:

Dim sbSelectedDate As New System.Text.StringBuilder()
For Each dt As DateTime In Me.xamMonthCalendar1.SelectedDates
    sbSelectedDate.AppendLine(dt.ToShortDateString())
Next
MessageBox.Show("Selected Dates: " & sbSelectedDate.ToString())

In C#:

StringBuilder sbSelectedDate = new StringBuilder();
foreach (DateTime dt in this.xamMonthCalendar1.SelectedDates)
{
    sbSelectedDate.AppendLine(dt.ToShortDateString());
}
MessageBox.Show("Selected Dates: " + sbSelectedDate.ToString());