MonthCalendar Control (VBCCRMonthCalendar)
The VBCCRMonthCalendar control provides a complete calendar interface where users can view and select dates. It supports multiple selection, range selection, holiday display, and other features.
Properties
Date-related Properties
Value: Currently selected dateSelectionStart: Start date of selection rangeSelectionEnd: End date of selection rangeMinDate: Minimum selectable dateMaxDate: Maximum selectable dateFirstDayOfWeek: First day of the weekMaxSelCount: Maximum number of days that can be selected
Display Properties
MonthRows: Number of month rows to displayMonthColumns: Number of month columns to displayShowToday: Whether to show todayShowTodayCircle: Whether to show circle around today's dateShowWeekNumbers: Whether to show week numbersDayState: Date state (for marking special dates)BackColor: Background colorTitleBackColor: Title background colorTitleForeColor: Title foreground colorTrailingForeColor: Foreground color for dates not in current month
Methods
Date Operations
vb
' Set date range
SetSelectionRange(StartDate As Date, EndDate As Date)
' Get selection range
GetSelectionRange(StartDate As Date, EndDate As Date)
' Set current date
SetCurSel(NewDate As Date)
' Get current date
GetCurSel() As Date
' Set today's date
SetToday(NewDate As Date)
' Get today's date
GetToday() As DateEvents
DateChanged(): Triggered when selected date changesSelectionChanged(): Triggered when selection range changesGetDayBold(ByVal StartDate As Date, ByVal Count As Long, ByRef State() As Boolean): Get date bold stateClick(): Triggered when date is clicked
Code Examples
Basic Usage
vb
Private Sub InitMonthCalendar()
With MonthCalendar1
' Set date range
.MinDate = DateSerial(2000, 1, 1)
.MaxDate = DateSerial(2030, 12, 31)
' Set current date
.Value = Date
' Display settings
.ShowToday = True
.ShowTodayCircle = True
.ShowWeekNumbers = True
' Set display layout
.MonthRows = 1
.MonthColumns = 2
End With
End SubDate Range Selection
vb
Private Type DateRange
StartDate As Date
EndDate As Date
Days As Long
End Type
Private Selection As DateRange
Private Sub MonthCalendar1_SelectionChanged()
With MonthCalendar1
' Get selection range
Selection.StartDate = .SelectionStart
Selection.EndDate = .SelectionEnd