An instance of the SpecialDateClass class describes a date that a calendar shows differently, such as a holiday.
Special dates are kept in the CalendarClass.SpecialDates collection of a CalendarClass object. A special date can repeat every week, month or year (SpecialDateClass.Recurrence property), which months and years are determined by the calendar of the control's culture. For dates that follow other rules, use the SftDate.DayFormatting event.
Namespace: Softelvdm.SftDateNET
Assembly: Softelvdm.SftDateNET
Inheritance
public class SpecialDateClass : System.ComponentModel.INotifyPropertyChanged;
Public Class SpecialDateClass
Implements System.ComponentModel.INotifyPropertyChanged![]() | SpecialDateClass | Initializes a new instance of the SpecialDateClass class for today's date. |
![]() | BackColor | Defines the background color of the day. |
![]() | Bold | Defines whether the day is shown in bold. |
![]() | Date | Defines the date. |
![]() | Enabled | Defines whether the day can be selected. |
![]() | ForeColor | Defines the text color of the day. |
![]() | Image | Defines an image shown with the day. |
![]() | Recurrence | Defines how the special date repeats. |
![]() | Tag | Defines application data associated with the special date. |
![]() | ToolTip | Defines the tooltip shown for the day. |
![]() | AppliesTo | Returns whether the special date applies to a date. |
![]() ![]() | Equals | Determines whether the specified object is equal to the current object. |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. |
![]() ![]() | GetHashCode | Serves as the default hash function. |
![]() ![]() | GetType | Gets the Type of the current instance. |
![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. |
![]() ![]() ![]() | ReferenceEquals | Determines whether the specified Object instances are the same instance. |
![]() ![]() | ToString | Returns a string that represents the current object. |
![]() | PropertyChanged | Occurs when a property of the special date changes. |
// Special dates repeat every year, month or week, and can be bold, colored, disabled or show a tooltip.
private void checkHolidays_CheckedChanged(object sender, EventArgs e) {
int year = DateTime.Today.Year;
DateTime monday = DateTime.Today.AddDays(-(((int)DateTime.Today.DayOfWeek + 6) % 7));
ForEachCalendar(delegate (CalendarClass calendar) {
calendar.SpecialDates.Clear();
if (!checkHolidays.Checked)
return;
SpecialDateClass day = calendar.SpecialDates.Add(new DateTime(year, 1, 1), RecurrenceEnum.Annually);
day.Bold = true;
day.ForeColor = Color.Firebrick;
day.ToolTip = "New Year's Day";
day = calendar.SpecialDates.Add(new DateTime(year, 7, 4), RecurrenceEnum.Annually);
day.Bold = true;
day.ForeColor = Color.Firebrick;
day.ToolTip = "Independence Day";
' Special dates repeat every year, month or week, and can be bold, colored, disabled or show a tooltip.
Private Sub CheckHolidays_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckHolidays.CheckedChanged
Dim year As Integer = DateTime.Today.Year
Dim monday As DateTime = DateTime.Today.AddDays(-((CInt(DateTime.Today.DayOfWeek) + 6) Mod 7))
For Each calendar As CalendarClass In AllCalendars()
calendar.SpecialDates.Clear()
If CheckHolidays.Checked Then
Dim day As SpecialDateClass = calendar.SpecialDates.Add(New DateTime(year, 1, 1), RecurrenceEnum.Annually)
day.Bold = True
day.ForeColor = Color.Firebrick
day.ToolTip = "New Year's Day"
day = calendar.SpecialDates.Add(New DateTime(year, 7, 4), RecurrenceEnum.Annually)
day.Bold = True
day.ForeColor = Color.Firebrick
day.ToolTip = "Independence Day"
day = calendar.SpecialDates.Add(New DateTime(year, 12, 25), RecurrenceEnum.Annually)See Also Classes | SftDate/NET 3.0