Articles in this section
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.

Before disabling the previous or next month cell

Figure 1. Before disabling the previous or next month cell.

After disabling the previous or next month cell

Figure 2. After disabling the previous or next month cell with transparent backcolor.

Samples:

C#: MonthCalendar_DisableDateSelection_C#

VB: MonthCalendar_DisableDateSelection_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied