Articles in this section
Category / Section

How to customize the label, marker and reminder colors of appointments in WinForms ScheduleControl?

1 min read

Customize the label, marker and reminder color of appointments

By default, the color will be set to appointment based on IScheduleAppointment.LabelValue. In order to change the custom color for the appointment label, DrawCellDisplayText event can be used.

C#

//Event Subscription
this.scheduleControl1.GetScheduleHost().DrawCellDisplayText += Form1_DrawCellDisplayText;
 
//Event Customization
void Form1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e)
{
    if (e.Style.CellValue.ToString().Contains("subject"))
    {
        Color c = ((ListObject)scheduleProvider.GetLocations()[2]).ColorMember;
        Rectangle rect = e.TextRectangle;
        rect.Y += 16;
        rect.Height -= 16;
        e.Graphics.FillRectangle(new SolidBrush(c), rect.X, rect.Y + 10, rect.Width - 2, 20);
        e.Graphics.DrawString("Subject  Mon:Tue", e.Style.GdipFont, new SolidBrush(e.Style.TextColor), new Point(rect.X + 2, rect.Y + 12));
    }
}

VB

'Event Subscription
AddHandler Me.scheduleControl1.GetScheduleHost().DrawCellDisplayText, AddressOf Form1_DrawCellDisplayText
 
'Event Customization
Private Sub Form1_DrawCellDisplayText(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs)
    If e.Style.CellValue.ToString().Contains("subject") Then
        Dim c As Color = (CType(scheduleProvider.GetLocations()(2), ListObject)).ColorMember
        Dim rect As Rectangle = e.TextRectangle
        rect.Y += 16
        rect.Height -= 16
        e.Graphics.FillRectangle(New SolidBrush(c), rect.X, rect.Y + 10, rect.Width - 2, 20)
        e.Graphics.DrawString("Subject  Mon:Tue", e.Style.GdipFont, New SolidBrush(e.Style.TextColor), New Point(rect.X + 2, rect.Y + 12))
    End If
End Sub

Screenshot

Customize the label, marker and reminder color

Note:

The Grid.Windows.dll should be added to the assembly reference to access the DrawCellDisplayText event.

Samples:

C#: Custom_Appointment_Color_CS

VB: Custom_Appointment_Color_VB

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