When the user selects a date range, what method do I use to get the date range that has been selected?
The selected dates are exposed via the UltraCalendarInfo.SelectedDateRanges collection. This collection contains objects of type DateRange, which encapsulates a contiguous range of dates. Since discontiguous selection of dates is supported in WinSchedule, this collection can contain more than one member (one for each contiguous block of selected dates).
Ok, thank you....now what about setting the entire month to automatically be selected when the calendar comes up. In Outlook when you scroll to the next month, it also automatically selects the next month as the selected date range.
How do you set the default to automatically select the entire month? BTW, you've been very helpful.
achinn said:How do you set the default to automatically select the entire month?
Example:
DateTime start = new DateTime( DateTime.Today.Year, DateTime.Today.Month, 1 );int daysInMonth = System.Globalization.CultureInfo.CurrentCulture.Calendar.GetDaysInMonth( DateTime.Today.Year, DateTime.Today.Month );DateTime end = new DateTime( DateTime.Today.Year, DateTime.Today.Month, daysInMonth );this.calendarInfo.SelectedDateRanges.Add(start, end, true );
That works great for selecting the current month. Ok, so now what if you want to know exactly which dates are being displayed to the user? For example, in outlook, if you bring up the current month the leading and trailing dates are also selected.
So, if you wanted to also include the leading and trailing dates in your SelectedDateRange, how would you interrogate the control to get those dates?
You would have to do something like walk backwards from the first day of the month until you hit the first day of the week, and include those days as well. Walk forward from the last day of the month until you hit last day of the week in the same manner.