# scheduler-cell-customization

> SfCalendar whose month cells show per-day appointment markers and whose year view swaps in a custom icon, drawn through the DrawCell event.

**Framework:** winforms  **Component:** Scheduler  **Variant:** cell-customization

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/winforms/scheduler-cell-customization.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.SfInput.WinForms
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/scheduler-cell-customization/scheduler.Designer.cs

```cs
﻿#region Copyright Syncfusion Inc. 2001-2018.
// Copyright Syncfusion Inc. 2001-2018. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws. 
#endregion
using System.Drawing;

namespace CellCustomization
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.panel4 = new System.Windows.Forms.Panel();
            this.sfCalendar1 = new Syncfusion.WinForms.Input.SfCalendar();
            this.panel2 = new System.Windows.Forms.Panel();
            this.panel3 = new System.Windows.Forms.Panel();
            this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
            this.panel5 = new System.Windows.Forms.Panel();
            this.panel4.SuspendLayout();
            this.panel2.SuspendLayout();
            this.panel3.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel4
            // 
            this.panel4.Controls.Add(this.panel3);
            this.panel4.Controls.Add(this.sfCalendar1);
            this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel4.Location = new System.Drawing.Point(0, 0);
            this.panel4.Name = "panel4";
            this.panel4.Size = new System.Drawing.Size(878, 653);
            this.panel4.TabIndex = 1;
            // 
            // sfCalendar1
            // 
            this.sfCalendar1.Culture = new System.Globalization.CultureInfo("en-US");
            this.sfCalendar1.Location = new System.Drawing.Point(84, 63);
            this.sfCalendar1.MaxDate = new System.DateTime(9999, 12, 31, 23, 59, 59, 999);
            this.sfCalendar1.Name = "sfCalendar1";
            this.sfCalendar1.Size = new System.Drawing.Size(518, 461);
            this.sfCalendar1.TabIndex = 0;
            this.sfCalendar1.Text = "sfCalendar1";
            this.sfCalendar1.ThemeName = null;
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.panel5);
            this.panel2.Controls.Add(this.panel4);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel2.Location = new System.Drawing.Point(2, 30);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(878, 653);
            this.panel2.TabIndex = 1;
            // 
            // panel3
            // 
            this.panel3.Controls.Add(this.flowLayoutPanel1);
            this.panel3.Location = new System.Drawing.Point(660, 45);
            this.panel3.Name = "panel3";
            this.panel3.Size = new System.Drawing.Size(488, 479);
            this.panel3.TabIndex = 1;
            // 
            // flowLayoutPanel1
            // 
            this.flowLayoutPanel1.AutoScroll = true;
            this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
            this.flowLayoutPanel1.Name = "flowLayoutPanel1";
            this.flowLayoutPanel1.Size = new System.Drawing.Size(488, 479);
            this.flowLayoutPanel1.TabIndex = 0;
            // 
            // panel5
            // 
            this.panel5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244)))));
            this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel5.Location = new System.Drawing.Point(0, 0);
            this.panel5.Name = "panel5";
            this.panel5.Size = new System.Drawing.Size(878, 2);
            this.panel5.TabIndex = 2;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = ColorTranslator.FromHtml("#F3F3F3");
            this.ClientSize = new System.Drawing.Size(882, 685);
            this.Controls.Add(this.panel2);
            this.MaximizeBox = false;
            this.MaximumSize = new System.Drawing.Size(885, 725);
            this.MinimumSize = new System.Drawing.Size(885, 725);
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Cell customization";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.panel4.ResumeLayout(false);
            this.panel2.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Panel panel4;
        private Syncfusion.WinForms.Input.SfCalendar sfCalendar1;
        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.Panel panel3;
        private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
        private System.Windows.Forms.Panel panel5;
    }
}

```

### src/components/scheduler-cell-customization/scheduler.cs

```cs
using Syncfusion.WinForms.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CellCustomization
{
    /// <summary>
    /// Demonstrates the SfCalendar cell customization: the month cells show a
    /// marker for every appointment and the year view shows an icon per month.
    /// </summary>
    public partial class Form1 : SfForm
    {
        #region Variables

        /// <summary>
        /// Holds the appointments that are shown on the calendar.
        /// </summary>
        private List<CellCustomizationDataSource.Appointment> m_Appointment =
            new List<CellCustomizationDataSource.Appointment>();

        /// <summary>
        /// The colours that have already been handed out to a time range.
        /// </summary>
        private List<string> usedColors = new List<string>();

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        public Form1()
        {
            InitializeComponent();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the appointments that are shown on the calendar.
        /// </summary>
        public List<CellCustomizationDataSource.Appointment> Appointment
        {
            get { return m_Appointment; }
        }

        #endregion

        #region Events

        /// <summary>
        /// Prepares the form and fills the calendar with appointments when it is loaded.
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            this.sfCalendar1.SelectionChanged += SfCalendar1_SelectionChanged;
            this.sfCalendar1.DrawCell += SfCalendar1_DrawCell1;
            this.sfCalendar1.HighlightTodayCell = false;

            this.m_Appointment = CellCustomizationDataSource.CreateAppointments();

            this.sfCalendar1.Style.Cell.CellFont = new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size + 2);
            this.sfCalendar1.Style.Cell.TrailingCellFont = new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size + 2);
            this.sfCalendar1.Style.Cell.SelectedCellFont = new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size + 2);
            this.sfCalendar1.SelectedDate = this.Appointment[0].Date;

            SfSkinManager.SetVisualStyle(this, "Office2019Colorful");
        }

        /// <summary>
        /// Brightens or darkens the supplied colour.
        /// </summary>
        public static Color ChangeColorBrightness(Color color, float correctionFactor)
        {
            float red = (float)color.R;
            float green = (float)color.G;
            float blue = (float)color.B;

            if (correctionFactor < 0)
            {
                correctionFactor = 1 + correctionFactor;
                red *= correctionFactor;
                green *= correctionFactor;
                blue *= correctionFactor;
            }
            else
            {
                red = (255 - red) * correctionFactor + red;
                green = (255 - green) * correctionFactor + green;
                blue = (255 - blue) * correctionFactor + blue;
            }

            return Color.FromArgb(color.A, (int)red, (int)green, (int)blue);
        }

        /// <summary>
        /// Draws the customized calendar cells.
        /// </summary>
        private void SfCalendar1_DrawCell1(Syncfusion.WinForms.Input.SfCalendar sender, Syncfusion.WinForms.Input.Events.DrawCellEventArgs args)
        {
            if (!args.Value.HasValue)
            {
                return;
            }

            if (args.ViewType == Syncfusion.WinForms.Input.Enums.CalendarViewType.Year)
            {
                Image image = CellCustomizationDataSource.GetYearIcon(args.Value.Value.Month, args.Value.Value.Year);
                if (image != null)
                {
                    args.Handled = true;
                    args.Graphics.DrawImage(image, args.CellBounds);
                }

                return;
            }

            if (args.ViewType != Syncfusion.WinForms.Input.Enums.CalendarViewType.Month)
            {
                return;
            }

            args.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            int startPosition = 0;
            CellCustomizationDataSource.Appointment appointment =
                CellCustomizationDataSource.FindAppointment(this.Appointment, args.Value.Value.Date);

            if (appointment != null && (args.Value.Value.DayOfWeek != DayOfWeek.Sunday))
            {
                args.Handled = true;

                for (int index = 0; index < appointment.Appointments.Count; index++)
                {
                    Color markerColor = args.IsTrailingDate
                        ? ControlPaint.LightLight(appointment.Appointments[index].AppointmentColor)
                        : appointment.Appointments[index].AppointmentColor;

                    args.Graphics.FillRectangle(
                        new SolidBrush(markerColor),
                        new Rectangle(
                            (args.CellBounds.X + (args.CellBounds.Width - args.CellBounds.Width / 2)) -
                            (appointment.Appointments.Count * 2) - (appointment.Appointments.Count * 6) - startPosition,
                            (args.CellBounds.Y + (args.CellBounds.Height - 20)),
                            12,
                            12));

                    startPosition -= 18;
                }

                TextRenderer.DrawText(
                    args.Graphics,
                    args.Value.Value.Day.ToString(),
                    new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size),
                    args.CellBounds,
                    args.IsTrailingDate ? ControlPaint.LightLight(Color.IndianRed) : Color.IndianRed,
                    TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
            }
            else
            {
                args.Handled = true;

                if (!args.IsTrailingDate)
                {
                    TextRenderer.DrawText(
                        args.Graphics,
                        args.Value.Value.Day.ToString(),
                        new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size),
                        args.CellBounds,
                        this.sfCalendar1.Style.Cell.CellForeColor,
                        TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
                }
                else
                {
                    TextRenderer.DrawText(
                        args.Graphics,
                        args.Value.Value.Day.ToString(),
                        new Font("Segoe UI", this.sfCalendar1.Style.Cell.CellFont.Size),
                        args.CellBounds,
                        ControlPaint.LightLight(this.sfCalendar1.Style.Cell.TrailingCellForeColor),
                        TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
                }
            }
        }

        /// <summary>
        /// Unsubscribes from the calendar events when the form is closed.
        /// </summary>
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            this.Load -= new EventHandler(Form1_Load);
            this.sfCalendar1.SelectionChanged -= SfCalendar1_SelectionChanged;
            this.sfCalendar1.DrawCell -= new Syncfusion.WinForms.Input.Events.DrawCellEventHandler(SfCalendar1_DrawCell1);
            base.OnClosing(e);
        }

        /// <summary>
        /// Lists the appointments of the selected date in the side panel.
        /// </summary>
        private void SfCalendar1_SelectionChanged(Syncfusion.WinForms.Input.SfCalendar sender, Syncfusion.WinForms.Input.Events.SelectionChangedEventArgs args)
        {
            LockWindowUpdate(this.panel3.Handle);
            this.flowLayoutPanel1.Controls.Clear();

            if (this.sfCalendar1.SelectedDate == null)
            {
                LockWindowUpdate(IntPtr.Zero);
                return;
            }

            EventHeaderControl headerControl = new EventHeaderControl();
            headerControl.EventHeaderLabel.Text = "Appointments";
            this.flowLayoutPanel1.Controls.Add(headerControl);

            SelectedDateControl selectedDateControl = new SelectedDateControl();
            selectedDateControl.SelectedDateLabel.Text = this.sfCalendar1.SelectedDate.Value.ToString("dddd, dd MMMM yyyy");
            this.flowLayoutPanel1.Controls.Add(selectedDateControl);

            CellCustomizationDataSource.Appointment appointment =
                CellCustomizationDataSource.FindAppointment(this.Appointment, this.sfCalendar1.SelectedDate.Value);

            if (appointment != null)
            {
                for (int index = 0; index < appointment.Appointments.Count; index++)
                {
                    AppointmentControl appointmentControl = new AppointmentControl();
                    appointmentControl.DescriptionLbl.Text = appointment.Appointments[index].Description;
                    appointmentControl.TimeLbl.Text = appointment.Appointments[index].Time;

                    if (this.sfCalendar1.SelectedDate.Value.DayOfWeek != DayOfWeek.Sunday)
                    {
                        this.flowLayoutPanel1.Controls.Add(appointmentControl);
                    }
                }
            }

            if (this.flowLayoutPanel1.Controls.Count == 2 ||
                this.sfCalendar1.SelectedDate.Value.DayOfWeek == DayOfWeek.Sunday)
            {
                NoAppointmentControl noAppointmentControl = new NoAppointmentControl();
                noAppointmentControl.NoAppointmentLabel.Text = "No Appointments";
                this.flowLayoutPanel1.Controls.Add(noAppointmentControl);
            }

            LockWindowUpdate(IntPtr.Zero);
            this.flowLayoutPanel1.Refresh();
        }

        #endregion

        #region Native

        /// <summary>
        /// Locks the window repaint while the side panel is rebuilt.
        /// </summary>
        [DllImport("user32.dll")]
        private static extern long LockWindowUpdate(IntPtr handle);

        #endregion
    }
}

```
