HeaderPane
Main
Hide
Share Link
Print

SpecialDateClass Class

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

Syntax

public class SpecialDateClass : System.ComponentModel.INotifyPropertyChanged;
Public Class SpecialDateClass
    Implements System.ComponentModel.INotifyPropertyChanged

Constructors

PublicSpecialDateClassInitializes a new instance of the SpecialDateClass class for today's date.

Properties

PublicBackColorDefines the background color of the day.
PublicBoldDefines whether the day is shown in bold.
PublicDateDefines the date.
PublicEnabledDefines whether the day can be selected.
PublicForeColorDefines the text color of the day.
PublicImageDefines an image shown with the day.
PublicRecurrenceDefines how the special date repeats.
PublicTagDefines application data associated with the special date.
PublicToolTipDefines the tooltip shown for the day.

Methods

PublicAppliesToReturns whether the special date applies to a date.
PublicInherited from System.ObjectEqualsDetermines whether the specified object is equal to the current object.
ProtectedInherited from System.ObjectFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
PublicInherited from System.ObjectGetHashCodeServes as the default hash function.
PublicInherited from System.ObjectGetTypeGets the Type of the current instance.
ProtectedInherited from System.ObjectMemberwiseCloneCreates a shallow copy of the current Object.
PublicStaticInherited from System.ObjectReferenceEqualsDetermines whether the specified Object instances are the same instance.
PublicInherited from System.ObjectToStringReturns a string that represents the current object.

Events

PublicPropertyChangedOccurs when a property of the special date changes.

Examples

C# View entire sample code

        // 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";

VB.NET View entire sample code

    ' 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