Category / Section
How to display current month details in WinForms MonthCalenderAdv?
1 min read
Display current month details
In MonthCalendarAdv, it is possible to display current Month details and disable selection, navigation for Inactive Month upon mouse selection by handling its event named QueryCellInfo.
C#
//To change the text color of the inactive month this.monthCalendarAdv1.InactiveMonthColor = Color.Transparent; //Handles the event to provide custom formating cells. this.monthCalendarAdv1.DateCellQueryInfo += new Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventHandler(monthCalendarAdv1_DateCellQueryInfo); //To disable the date selection while navigation to next or previous month, while selecting the date from current month void monthCalendarAdv1_DateCellQueryInfo(object sender, Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs e) { if (e.Style.TextColor == this.monthCalendarAdv1.InactiveMonthColor) e.Style.Enabled = false; }
VB
'To change the text color of the inactive month Me.monthCalendarAdv1.InactiveMonthColor = Color.Transparent 'Handles the event to provide custom formating cells. AddHandler monthCalendarAdv1.DateCellQueryInfo, AddressOf monthCalendarAdv1_DateCellQueryInfo 'To disable the date selection while navigation to next or previous month, while selecting the date from current month Private Sub monthCalendarAdv1_DateCellQueryInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs) If e.Style.TextColor = Me.monthCalendarAdv1.InactiveMonthColor Then e.Style.Enabled = False End If End Sub
Note:
The InactiveMonthColor is specified as transparent, to hide text from the cell.
Figure 1. Before disabling the previous or next month cell.
Figure 2. After disabling the previous or next month cell with transparent backcolor.
Samples: