2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Change the back color of special datesYou can set different colors for specific days in the Schedule control. This can be achieved by checking the Column index and using the QueryCellInfo event. In the following code example, different colors for the 5th and 6th columns are applied. C# //sets the color of prime time cells in the calendar. this.scheduleControl1.Appearance.PrimeTimeCellColor = Color.FromArgb(0, Color.Wheat); //sets the color of prime time cells in the calendar. this.scheduleControl1.Appearance.NonPrimeTimeCellColor = Color.FromArgb(0, Color.Wheat); this.scheduleControl1.GetScheduleHost().QueryCellInfo += new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Form1_QueryCellInfo); void Form1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { if (e.ColIndex == 5) { //Applies back color for 5th column. e.Style.BackColor = Color.LightSkyBlue; } if (e.ColIndex == 6) { //Applies back color for 6th column. e.Style.BackColor = Color.Pink; } }
VB 'Sets the color of prime time cells in the calendar. Me.scheduleControl1.Appearance.PrimeTimeCellColor = Color.FromArgb(0, Color.Wheat) 'Sets the color of Non-prime time cells in the calendar. Me.scheduleControl1.Appearance.NonPrimeTimeCellColor = Color.FromArgb(0, Color.Wheat) AddHandler scheduleControl1.GetScheduleHost().QueryCellInfo, AddressOf Form1_QueryCellInfo void Form1_QueryCellInfo(Object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) If e.ColIndex = 5 Then 'Applies back color for 5th column. e.Style.BackColor = Color.LightSkyBlue End If If e.ColIndex = 6 Then 'Applies back color for 6th column. e.Style.BackColor = Color.Pink End If End Sub
Samples: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
If I change the view to day and then back to month, the different colors for specific days disappeared.
Hi Felix,
Thanks for using Syncfusion product.
We can understand your scenario. If you change the schedule view, we have unwired this event internally. So, you need to trigger again this event using SetupContextMenu event. Please refer to the below code example,
Code example
this.scheduleControl1.SetupContextMenu += scheduleControl1_SetupContextMenu;
void scheduleControl1_SetupContextMenu(object sender, CancelEventArgs e)
{
if (this.scheduleControl1.ScheduleType == ScheduleViewType.Month)
{
this.scheduleControl1.GetScheduleHost().QueryCellInfo += Form1_QueryCellInfo;
}
}
Please let us know if you have any concerns.
Regards,
Mohanraj G