MonthView Control (VBCCRMonthView)
The VBCCRMonthView control provides a calendar interface that allows users to view and select dates. It supports single date selection, date range selection, and offers various customization options for display.
Properties
Key Properties
Value
: Currently selected dateMinDate
: Minimum selectable dateMaxDate
: Maximum selectable dateMultiSelect
: Whether to allow multiple date selectionSelectionRange
: Selected date rangeFirstDayOfWeek
: First day of the weekShowToday
: Whether to show today's dateShowWeekNumbers
: Whether to show week numbersBackColor
: Background colorForeColor
: Text colorMonthColumns
: Number of months displayed horizontallyMonthRows
: Number of months displayed vertically
Methods
Main Methods
GetSelectedRange(Start As Date, [End] As Date)
: Get selected date rangeSetSelectedRange(Start As Date, [End] As Date)
: Set selected date rangeHitTest(X As Single, Y As Single)
: Get date at specified coordinatesNavigate(Interval As Integer)
: Navigate to next/previous monthToday()
: Navigate to today
Events
DateClick(ByVal DateClicked As Date)
: Triggered when a date is clickedSelectionChange()
: Triggered when date selection changesGetDayBold(ByVal StartDate As Date, ByVal Count As Long, State() As Boolean)
: Set date bold displayMonthChange()
: Triggered when displayed month changes
Code Examples
Basic Usage
vb
Private Sub Form_Load()
With MonthView1
.Value = Date ' Set to today
.ShowToday = True
.ShowWeekNumbers = True
.FirstDayOfWeek = vbSunday
End With
End Sub
Date Range Selection
vb
Private Sub SetupDateRange()
With MonthView1
.MultiSelect = True
.MinDate = DateSerial(Year(Date), 1, 1)
.MaxDate = DateSerial(Year(Date), 12, 31)
' Set default selection range
.SetSelectedRange Date, DateAdd("d", 7, Date)
End With
End Sub
Private Sub MonthView1_SelectionChange()
Dim StartDate As Date
Dim EndDate As Date
MonthView1.GetSelectedRange StartDate, EndDate
Debug.Print "Selection Range: " & StartDate & " to " & EndDate
End Sub
Special Date Marking
vb
Private Sub MarkSpecialDates()
' Mark special dates in calendar
Dim SpecialDates() As Date
Dim i As Long
' Add special dates
ReDim SpecialDates(0 To 2)
SpecialDates(0) = Date
SpecialDates(1) = DateAdd("d", 7, Date)
SpecialDates(2) = DateAdd("d", 14, Date)
' Store special dates for later use
Set mSpecialDates = New Collection
For i = 0 To UBound(SpecialDates)
mSpecialDates.Add SpecialDates(i)
Next i
End Sub
Private Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Long, State() As Boolean)
Dim i As Long
Dim j As Long