)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display current month details in WinForms MonthCalenderAdv?

Platform: WinForms |
Control: MonthCalendarAdv |
Published Date: February 15, 2016 |
Last Revised Date: January 6, 2020

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon