Articles in this section
Category / Section

Customize the cell value of the WinForms MonthCalendar.

1 min read

Customize the cell value

The appearance and accessibility of the cell value can be customized by handling the event named, DateCellQueryInfo in the WinForms MonthCalendar. The following code example demonstrates the same.

C#

//Handles this event to provide custom formatting for calendar cells.
this.monthCalendarAdv1.DateCellQueryInfo += new Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventHandler(monthCalendarAdv1_DateCellQueryInfo);
void monthCalendarAdv1_DateCellQueryInfo(object sender, Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs e)
{
    if (this.monthCalendarAdv1.Value.Date == DateTime.Today)
    {
        //Disables the highlight color of the selected date value.
        e.EnableHighlightColor = false;
    }
    if (e.RowIndex == 3 || e.RowIndex == 4)
    {
        //Customizes the particular cell value.
        e.Style.BackColor = Color.Red;
        e.Style.TextColor = Color.White;
    }
}

VB

'Handles this event to provide custom formatting for calendar cells.
AddHandler monthCalendarAdv1.DateCellQueryInfo, AddressOf monthCalendarAdv1_DateCellQueryInfo
Private Sub monthCalendarAdv1_DateCellQueryInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs)
    If Me.monthCalendarAdv1.Value.Date = DateTime.Today Then
        'Disables the highlight color of the selected date value.
        e.EnableHighlightColor = False
    End If
    If e.RowIndex = 3 OrElse e.RowIndex = 4 Then
        'Customizes the particular cell value.
         e.Style.BackColor = Color.Red
         e.Style.TextColor = Color.White
    End If
End Sub

The following image shows the customized cell value of the MonthCalendarAdv:

Shows the customized cell value

Samples:

C#: http://www.syncfusion.com/downloads/support/directtrac/135929/MonthCalendar_CellCustomization-486933793.zip

VB: http://www.syncfusion.com/downloads/support/directtrac/135929/MonthCalendar_CellCustomization_VB-1008281778.zip


Conclusion

I hope you enjoyed learning about how to customize the cell value of the WinForms MonthCalendar.

You can refer to our  WinForms MonthCalendar feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms MonthCalendar documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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