Customize the cell value of the WinForms MonthCalendar.
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:
Samples:
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!