)
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 customize the WinForms MonthCalendarAdv dates as Bolded dates?

Platform: WinForms |
Control: MonthCalendarAdv |
Published Date: May 31, 2018 |
Last Revised Date: January 6, 2020

Customize the MonthCalendarAdv

User can customize the font style of specific dates as Bold. It can be achieved by handling DateQueryCellInfo event. Here we have added the required bolded dates in BoldDateTime list, then check its value with MonthCalenderAdv date cell value in DateQueryCellInfo event. If date value matched, font style of corresponding date changed to bold. The following code demonstrates the same.

C#

private List<DateTime> BoldDateTime = new List<DateTime>();
//Raise the event for Date cell customization
this.monthCalendarAdv1.DateCellQueryInfo += MonthCalendarAdv1_DateCellQueryInfo;
 
//Add Bold date 
BoldDateTime.Add(DateTime.Now.AddDays(+1));
BoldDateTime.Add(DateTime.Now.AddDays(+2));
BoldDateTime.Add(DateTime.Now.AddDays(+3)); 
BoldDateTime.Add(DateTime.Now.AddDays(-1));
BoldDateTime.Add(DateTime.Now.AddDays(-2));
 
private void MonthCalendarAdv1_DateCellQueryInfo(object sender, Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs e)
{
   /// <summary>
   /// check date value is equal for added bold date value
   /// If yes, it shows the date value as bold
   /// </summary>
   if(e.DateValue != null && (!BoldDateTime.Contains(Convert.ToDateTime(e.DateValue))))
   {
      for(int i = 0; i < BoldDateTime.Count; i++)
      {
        if(this.BoldDateTime[i].Date.ToString() == e.DateValue.ToString())
        {
          //enable Bold
          e.Style.Font.Bold = true;
        }
      }
   }
}

VB

Private BoldDateTime As New List(Of Date)()
'Raise the event for Date cell customization
 
AddHandler Me.monthCalendarAdv1.DateCellQueryInfo, AddressOf MonthCalendarAdv1_DateCellQueryInfo
 
'Add Bold date
BoldDateTime.Add(Date.Now.AddDays(+1))
BoldDateTime.Add(Date.Now.AddDays(+2))
BoldDateTime.Add(Date.Now.AddDays(+3))
BoldDateTime.Add(Date.Now.AddDays(-1))
BoldDateTime.Add(Date.Now.AddDays(-2))
 
Private Sub MonthCalendarAdv1_DateCellQueryInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs)
   ''' <summary>
   ''' check date value is equal for added bold date value
   ''' If yes, it shows the date value as bold
   ''' </summary>
   If e.DateValue IsNot Nothing AndAlso (Not    BoldDateTime.Contains(Convert.ToDateTime(e.DateValue))) Then
     For i As Integer = 0 To BoldDateTime.Count - 1
       If Me.BoldDateTime(i).Date.ToString() = e.DateValue.ToString() Then
         'enable Bold
         e.Style.Font.Bold = True
       End If
     Next i
   End If
End Sub

 

Screenshot

Show the customized date as bold

 

Samples:

C#:  MonthCalendarSample

VB:  MonthCalendarSample

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