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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the backcolor for all appointment dates in calendar in WinForms ScheduleControl?

Platform: WinForms |
Control: ScheduleControl
Tags: styling

Set back color for appointment date

You can set the background color for all the appointment dates in Schedule calendar by using PrepareViewStyleInfo event.  Set the IScheduleDataProvider class to get the appointment data from the datasource.


this.scheduleControl1.Calendar.CalenderGrid.PrepareViewStyleInfo += new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(CalenderGrid_PrepareViewStyleInfo);
// to apply the style for appointment dates
void CalenderGrid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
   DateTime dt;
   if (e.Style.Text.Length > 0 && DateTime.TryParse(e.Style.Text, out dt))
      GridControl grid = sender as GridControl;
      // to get appointment date from the datasource
      IScheduleDataProvider dataProvider = this.scheduleControl1.DataSource;
      IScheduleAppointmentList list = dataProvider.GetScheduleForDay(dt);
      if (list.Count > 0 && (e.RowIndex != 0 && e.RowIndex !=8) )
         // to apply the color for appointment
         e.Style.BackColor = Color.Red;


AddHandler scheduleControl1.Calendar.CalenderGrid.PrepareViewStyleInfo, AddressOf CalenderGrid_PrepareViewStyleInfo
‘ to apply the style for appointment dates
Private Sub CalenderGrid_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs)
    Dim dt As DateTime
    If e.Style.Text.Length > 0 AndAlso DateTime.TryParse(e.Style.Text, dt) Then
       Dim grid As GridControl = TryCast(sender, GridControl)
       ' to get appointment date from the datasource
       Dim dataProvider As IScheduleDataProvider = Me.scheduleControl1.DataSource
       Dim list As IScheduleAppointmentList = dataProvider.GetScheduleForDay(dt)
       If list.Count > 0 AndAlso (e.RowIndex <> 0 AndAlso e.RowIndex <> 8) Then
          'to apply the color for appointment
          e.Style.BackColor = Color.Red
       End If
    End If
End Sub

The following screenshot illustrates the output.

Apply back color of appointment dates

Figure 1: Apply back color of appointment dates

Samples: Appointment_Backcolor

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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