# scheduler-disabled-dates

> DateTime edit control that marks every weekend between minimum and maximum dates as a blackout date via the DisabledDates collection.

**Framework:** winforms  **Component:** Scheduler  **Variant:** disabled-dates

## 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-disabled-dates.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-disabled-dates/scheduler.Designer.cs

```cs
﻿#region Copyright Syncfusion Inc. 2001-2019.
// Copyright Syncfusion Inc. 2001-2019. 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 Syncfusion.WinForms.Input.Events;
using System;

namespace DisabledDates
{
    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.panel6 = new System.Windows.Forms.Panel();
            this.panel2 = new System.Windows.Forms.Panel();
            this.borderPanel1 = new System.Windows.Forms.Panel();
            this.maxDateTimeEdit = new Syncfusion.WinForms.Input.SfDateTimeEdit();
            this.label3 = new System.Windows.Forms.Label();
            this.minDateTimeEdit = new Syncfusion.WinForms.Input.SfDateTimeEdit();
            this.minDate_lbl = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.captionLbl = new System.Windows.Forms.Label();
            this.sfCalendar = new Syncfusion.WinForms.Input.SfCalendar();
            this.borderPanel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel6
            // 
            this.panel6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
            this.panel6.Dock = System.Windows.Forms.DockStyle.Right;
            this.panel6.Location = new System.Drawing.Point(892, 0);
            this.panel6.Name = "panel6";
            this.panel6.Size = new System.Drawing.Size(1, 48);
            this.panel6.TabIndex = 1;
            // 
            // panel2
            // 
            this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
            this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel2.Location = new System.Drawing.Point(0, 48);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(893, 1);
            this.panel2.TabIndex = 1;
            // 
            // borderPanel1
            // 
            this.borderPanel1.Controls.Add(this.maxDateTimeEdit);
            this.borderPanel1.Controls.Add(this.label3);
            this.borderPanel1.Controls.Add(this.minDateTimeEdit);
            this.borderPanel1.Controls.Add(this.minDate_lbl);
            this.borderPanel1.Controls.Add(this.label2);
            this.borderPanel1.Controls.Add(this.captionLbl);
            this.borderPanel1.Controls.Add(this.sfCalendar);
            this.borderPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.borderPanel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.borderPanel1.ForeColor = System.Drawing.SystemColors.WindowText;
            this.borderPanel1.Location = new System.Drawing.Point(0, 49);
            this.borderPanel1.Name = "borderPanel1";
            this.borderPanel1.Size = new System.Drawing.Size(893, 591);
            this.borderPanel1.TabIndex = 2;
            // 
            // maxDateTimeEdit
            //             
            this.maxDateTimeEdit.DateTimeEditingMode = Syncfusion.WinForms.Input.Enums.DateTimeEditingMode.Mask;
            this.maxDateTimeEdit.Font = new System.Drawing.Font("Segoe UI", 11.25F);
            this.maxDateTimeEdit.ForeColor = System.Drawing.Color.Black;
            this.maxDateTimeEdit.Location = new System.Drawing.Point(671, 172);
            this.maxDateTimeEdit.Margin = new System.Windows.Forms.Padding(2);
            this.maxDateTimeEdit.Name = "maxDateTimeEdit";
            this.maxDateTimeEdit.Size = new System.Drawing.Size(155, 29);
            this.maxDateTimeEdit.TabIndex = 3;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Location = new System.Drawing.Point(556, 176);
            this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(71, 20);
            this.label3.TabIndex = 23;
            this.label3.Text = "MaxDate";
            // 
            // minDateTimeEdit
            //             
            this.minDateTimeEdit.DateTimeEditingMode = Syncfusion.WinForms.Input.Enums.DateTimeEditingMode.Mask;            
            this.minDateTimeEdit.DropDownPopupAlignment = Syncfusion.WinForms.Input.Enums.DropDownPopupAlignment.Left;
            this.minDateTimeEdit.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.minDateTimeEdit.Location = new System.Drawing.Point(671, 102);
            this.minDateTimeEdit.Margin = new System.Windows.Forms.Padding(2);
            this.minDateTimeEdit.Name = "minDateTimeEdit";
            this.minDateTimeEdit.Size = new System.Drawing.Size(155, 29);
            this.minDateTimeEdit.TabIndex = 2;
            this.minDateTimeEdit.ValidationOption = Syncfusion.WinForms.Input.Enums.ValidationResetOption.Reset;
            // 
            // minDate_lbl
            // 
            this.minDate_lbl.AutoSize = true;
            this.minDate_lbl.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.minDate_lbl.Location = new System.Drawing.Point(555, 105);
            this.minDate_lbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.minDate_lbl.Name = "minDate_lbl";
            this.minDate_lbl.Size = new System.Drawing.Size(68, 20);
            this.minDate_lbl.TabIndex = 21;
            this.minDate_lbl.Text = "MinDate";
            this.minDate_lbl.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
            this.label2.Location = new System.Drawing.Point(178, 462);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(0, 20);
            this.label2.TabIndex = 20;
            // 
            // captionLbl
            // 
            this.captionLbl.AutoSize = true;
            this.captionLbl.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.captionLbl.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
            this.captionLbl.Location = new System.Drawing.Point(66, 462);
            this.captionLbl.Margin = new System.Windows.Forms.Padding(10, 0, 3, 0);
            this.captionLbl.Name = "captionLbl";
            this.captionLbl.Size = new System.Drawing.Size(106, 20);
            this.captionLbl.TabIndex = 19;
            this.captionLbl.Text = "Selected Date:";
            // 
            // sfCalendar
            //
            this.sfCalendar.Location = new System.Drawing.Point(70, 86);            
            this.sfCalendar.Name = "sfCalendar";            
            this.sfCalendar.NumberOfWeeksInView = 5;   
            this.sfCalendar.ShowFooter = false;            
            this.sfCalendar.Size = new System.Drawing.Size(420, 354);            
            this.sfCalendar.TabIndex = 1;
            this.sfCalendar.Text = "sfCalendar1";
            this.sfCalendar.TrailingDatesVisible = false;
            this.sfCalendar.SelectionChanged += new SelectionChangedEventHandler(this.sfCalendar_SelectionChanged);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(893, 640);
            this.Controls.Add(this.borderPanel1);
            this.Controls.Add(this.panel2);
            this.MaximizeBox = false;
            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;
            this.Name = "Form1";
            this.MaximizeBox = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Disabled Dates";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.borderPanel1.ResumeLayout(false);
            this.borderPanel1.PerformLayout();
            this.ResumeLayout(false);

        }

      
        #endregion

        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.Panel panel6;
        private System.Windows.Forms.Panel borderPanel1;
        private Syncfusion.WinForms.Input.SfCalendar sfCalendar;
        private System.Windows.Forms.Label captionLbl;
        private System.Windows.Forms.Label label2;
        private Syncfusion.WinForms.Input.SfDateTimeEdit maxDateTimeEdit;
        private System.Windows.Forms.Label label3;
        private Syncfusion.WinForms.Input.SfDateTimeEdit minDateTimeEdit;
        private System.Windows.Forms.Label minDate_lbl;
    }
}

```

### src/components/scheduler-disabled-dates/scheduler.cs

```cs
using Syncfusion.WinForms.Controls;
using Syncfusion.WinForms.Input;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace DisabledDates
{
    /// <summary>
    /// Demonstrates the SfCalendar blackout dates: the weekends inside the
    /// selected date range are disabled and the range can be changed at runtime.
    /// </summary>
    public partial class Form1 : SfForm
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Form1"/> class.
        /// </summary>
        public Form1()
        {
            InitializeComponent();
        }

        #region Functions

        /// <summary>
        /// Configures the default selectable date range of the calendar.
        /// </summary>
        public void ConfigureDateRange()
        {
            this.minDateTimeEdit.ValueChanged += MinDateTimeEdit_ValueChanged;
            this.maxDateTimeEdit.ValueChanged += MaxDateTimeEdit_ValueChanged;

            minDateTimeEdit.Value = DisabledDatesDataSource.GetDefaultMinDate();
            maxDateTimeEdit.Value = DisabledDatesDataSource.GetDefaultMaxDate();

            GetWeekends();

            this.sfCalendar.MinDate = minDateTimeEdit.Value.Value;
            this.sfCalendar.MaxDate = maxDateTimeEdit.Value.Value;
            this.minDateTimeEdit.MonthCalendar.ShowFooter = false;
            this.maxDateTimeEdit.MonthCalendar.ShowFooter = false;
            this.label2.Text = this.sfCalendar.SelectedDate.Value.ToLongDateString();
        }

        /// <summary>
        /// Centers the calendar panel inside the form.
        /// </summary>
        public void MakePanelCenter()
        {
            this.borderPanel1.Location = new Point(
                this.ClientSize.Width / 2 - borderPanel1.Size.Width / 2,
                this.ClientSize.Height / 2 - borderPanel1.Size.Height / 2);
        }

        /// <summary>
        /// Marks every weekend inside the selected range as a blackout date.
        /// </summary>
        public void GetWeekends()
        {
            List<DateTime> weekends = DisabledDatesDataSource.GetWeekends(
                minDateTimeEdit.Value.Value,
                maxDateTimeEdit.Value.Value);

            this.sfCalendar.BlackoutDates = weekends;
        }

        #endregion

        #region Events

        /// <summary>
        /// Applies the new maximum date to the calendar and refreshes the blackout dates.
        /// </summary>
        private void MaxDateTimeEdit_ValueChanged(object sender, Syncfusion.WinForms.Input.Events.DateTimeValueChangedEventArgs e)
        {
            this.sfCalendar.MaxDate = (sender as SfDateTimeEdit).Value.Value;
            this.minDateTimeEdit.MaxDateTime = (sender as SfDateTimeEdit).Value.Value;
            GetWeekends();
        }

        /// <summary>
        /// Applies the new minimum date to the calendar and refreshes the blackout dates.
        /// </summary>
        private void MinDateTimeEdit_ValueChanged(object sender, Syncfusion.WinForms.Input.Events.DateTimeValueChangedEventArgs e)
        {
            this.sfCalendar.MinDate = (sender as SfDateTimeEdit).Value.Value;
            this.maxDateTimeEdit.MinDateTime = (sender as SfDateTimeEdit).Value.Value;
            GetWeekends();
        }

        /// <summary>
        /// Prepares the form when it is loaded.
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            MakePanelCenter();
            ConfigureDateRange();
            UpdateVisualStyle();
        }

        /// <summary>
        /// Applies the visual style used by the sample.
        /// </summary>
        private void UpdateVisualStyle()
        {
            this.label2.ForeColor = ColorTranslator.FromHtml("#444444");
            this.label3.ForeColor = ColorTranslator.FromHtml("#444444");
            this.captionLbl.ForeColor = ColorTranslator.FromHtml("#444444");
            this.BackColor = ColorTranslator.FromHtml("#f3f3f3");
            SfSkinManager.SetVisualStyle(this, "Office2019Colorful");
        }

        /// <summary>
        /// Keeps the calendar panel centered while the form is resized.
        /// </summary>
        protected override void OnSizeChanged(EventArgs e)
        {
            MakePanelCenter();
            base.OnSizeChanged(e);
        }

        /// <summary>
        /// Shows the date that is currently selected.
        /// </summary>
        private void sfCalendar_SelectionChanged(object sender, Syncfusion.WinForms.Input.Events.SelectionChangedEventArgs e)
        {
            if (this.sfCalendar.SelectedDate == null)
            {
                this.label2.Text = "None";
            }
            else
            {
                this.label2.Text = this.sfCalendar.SelectedDate.Value.ToLongDateString();
            }
        }

        #endregion
    }
}

```
