Loading...
Loading...
Guides implementation of Syncfusion WinForms SfCalendar control for date selection and calendar viewing. Use this when working with calendar controls, date pickers, or multi-view calendars with Month/Year/Decade/Century views. Covers date selection modes, view navigation, date restrictions, special dates, and appearance customization for Windows Forms.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-calendarSfCalendarSyncfusion.WinForms.InputSyncfusion.Core.WinForms.dllSyncfusion.SfInput.WinForms.dllSyncfusion.Shared.Base.dllusing Syncfusion.WinForms.Input;
using System;
using System.Windows.Forms;
public class CalendarForm : Form
{
private SfCalendar calendar;
private Label lblSelected;
public CalendarForm()
{
// Create calendar
calendar = new SfCalendar
{
Location = new Point(20, 20),
Size = new Size(350, 300)
};
// Handle selection change
calendar.SelectedDateChanged += Calendar_SelectedDateChanged;
// Create label to show selected date
lblSelected = new Label
{
Location = new Point(20, 330),
Size = new Size(350, 30),
Text = "No date selected"
};
this.Controls.Add(calendar);
this.Controls.Add(lblSelected);
this.Text = "Calendar Example";
this.Size = new Size(400, 420);
}
private void Calendar_SelectedDateChanged(object sender, EventArgs e)
{
if (calendar.SelectedDate.HasValue)
{
lblSelected.Text = $"Selected: {calendar.SelectedDate.Value:D}";
}
}
}Imports Syncfusion.WinForms.Input
Imports System
Imports System.Windows.Forms
Public Class CalendarForm
Inherits Form
Private calendar As SfCalendar
Private lblSelected As Label
Public Sub New()
' Create calendar
calendar = New SfCalendar With {
.Location = New Point(20, 20),
.Size = New Size(350, 300)
}
' Handle selection change
AddHandler calendar.SelectedDateChanged, AddressOf Calendar_SelectedDateChanged
' Create label to show selected date
lblSelected = New Label With {
.Location = New Point(20, 330),
.Size = New Size(350, 30),
.Text = "No date selected"
}
Me.Controls.Add(calendar)
Me.Controls.Add(lblSelected)
Me.Text = "Calendar Example"
Me.Size = New Size(400, 420)
End Sub
Private Sub Calendar_SelectedDateChanged(sender As Object, e As EventArgs)
If calendar.SelectedDate.HasValue Then
lblSelected.Text = $"Selected: {calendar.SelectedDate.Value:D}"
End If
End Sub
End ClassSfCalendar calendar = new SfCalendar();
// Restrict to future dates only (starting from today)
calendar.MinDate = DateTime.Today;
calendar.MaxDate = DateTime.Today.AddMonths(6);
// Set initial date
calendar.SelectedDate = DateTime.Today;SfCalendar calendar = new SfCalendar();
// Add special dates (appointments, holidays, etc.)
calendar.SpecialDates.Add(new SpecialDate
{
Date = new DateTime(2026, 3, 25),
Description = "Team Meeting",
IconImage = Properties.Resources.MeetingIcon
});
calendar.SpecialDates.Add(new SpecialDate
{
Date = new DateTime(2026, 3, 28),
Description = "Project Deadline",
IconImage = Properties.Resources.DeadlineIcon
});SfCalendar calendar = new SfCalendar();
// Enable multiple selection
calendar.AllowMultipleSelection = true;
// Get selected dates
calendar.SelectionChanged += (s, e) =>
{
var dates = calendar.SelectedDates;
MessageBox.Show($"Selected {dates.Count} dates");
};| Property | Type | Description |
|---|---|---|
| SelectedDate | | Gets or sets the currently selected date |
| SelectedDates | | Gets or sets collection of selected dates for multiple selection |
| MinDate | | Minimum selectable date |
| MaxDate | | Maximum selectable date |
| AllowMultipleSelection | | Enables multiple date selection |
| ShowToday | | Shows or hides Today button |
| ShowNone | | Shows or hides None button for clearing selection |
| BlackoutDates | | Collection of dates to block from selection |
| SpecialDates | | Collection of special dates with icons and descriptions |
| Culture | | Culture for localization and formatting |
| FirstDayOfWeek | | First day of the week (Sunday, Monday, etc.) |
| Style | | Visual style settings for appearance |