Retrieves the first and last date of the currently displayed date range and returns the number of months than span the display.
MonthCalendar control
controlname.GetDisplayRange ( start, end {, d } )
Argument |
Description |
---|---|
controlname |
The name of the MonthCalendar control for which you want the range of dates |
start |
A date specifying the first date in the displayed range returned by reference |
end |
A date specifying the last date in the displayed range returned by reference |
d (optional) |
A value of the MonthCalDisplayState enumerated variable. Values are:
|
Integer. Returns the number of months in the display range if it succeeds and -1 if it fails.
The GetDisplayRange function retrieves the beginning and end dates of the range of dates currently displayed in the calendar.
If you do not supply the optional d argument (or specify PartlyDisplayed!), GetDisplayRange returns the number of months for which any of the days in the month display. If the calendar displays one month, the return value is 3, because the last few days of the previous month and the first few days of the next month are included.
If you supply EntirelyDisplayed! as the d argument, GetDisplayRange returns the number of months for which all of the days in the month display. It ignores the leading and trailing days.
For example, if the calendar display shows the 12 months from November 2004 to October 2005 and you do not supply the d argument, GetDisplayRange returns 14 and the start and end arguments are set to October 25, 2004 and November 6, 2005.
If you supply EntirelyDisplayed! as the d argument, GetDisplayRange returns 12 and the start and end arguments are set to November 1, 2004 and October 31, 2005.
This example displays a message box that shows the number of months in the display range and its start and end dates. Because the third argument is set to PartlyDisplayed!, the range returned will be greater than the number of full months displayed. If only one month displays and it neither begins on the first day of the week nor ends on the last day of the week, li_return will be 3:
integer li_return Date startdate, enddate string str1, string str2 li_return = mc_1.GetDisplayRange(startdate, enddate, & PartlyDisplayed!) str1 = "Range is " + string(li_return) + " months" str2 = "Start date is " + string(startdate) + "~r~n" str2 += "End date is " + string(enddate) MessageBox(str1, str2)
This example finds out how many complete months are shown in the current display and sets the scroll rate to that number:
integer li_return Date startdate, enddate li_return = mc_1.GetDisplayRange(startdate, enddate, & EntirelyDisplayed!) mc_1.ScrollRate = li_return