Table of Contents

Class ExCalendar

Namespace
ExControls
Assembly
ExControls.dll

Month calendar control drawn completely by the library (no Win32 MonthCalendar). Used standalone or as the drop-down part of ExDateTimePicker.

[ToolboxBitmap(typeof(ToolboxIcons), "Toolbox.ExCalendar.ico")]
public class ExCalendar : Control, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, IExControl, IThemeable
Inheritance
ExCalendar
Implements
Inherited Members
Extension Methods

Constructors

ExCalendar()

Initializes a new instance of the ExCalendar class in the default style, showing the current month with today's date selected.

public ExCalendar()

Properties

ArrowColor

Color of the previous/next month arrows.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the previous/next month arrows.")]
public Color ArrowColor { get; set; }

Property Value

Color

AutoSize

This property is not relevant for this class.

[Browsable(true)]
public override bool AutoSize { get; set; }

Property Value

bool

true if enabled; otherwise, false.

BackColor

Gets or sets the background color for the control.

public override Color BackColor { get; set; }

Property Value

Color

A Color that represents the background color of the control. The default is the value of the DefaultBackColor property.

BorderColor

Color of the border.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the border.")]
public Color BorderColor { get; set; }

Property Value

Color

DayOfWeekForeColor

Color of the day-of-week names.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the day-of-week names.")]
public Color DayOfWeekForeColor { get; set; }

Property Value

Color

DefaultSize

Gets the default size of the control.

protected override Size DefaultSize { get; }

Property Value

Size

The default Size of the control.

DefaultStyle

Gets or sets whether the control uses the default Windows style; false = the custom style drawn by the control with its own colors.

[Browsable(true)]
[ExCategory(CategoryType.Appearance)]
[ExDescription("Default style of the Control.")]
public bool DefaultStyle { get; set; }

Property Value

bool

DisabledForeColor

Color of the days outside of the MinDate-MaxDate range and of all text when the control is disabled.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the days outside of the MinDate-MaxDate range and of all text when the control is disabled.")]
public Color DisabledForeColor { get; set; }

Property Value

Color

DisplayMonth

First day of the displayed month.

[Browsable(false)]
public DateTime DisplayMonth { get; set; }

Property Value

DateTime

DrawBorder

Draws a one pixel border around the control.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Draws a one pixel border around the control.")]
public bool DrawBorder { get; set; }

Property Value

bool

FirstDayOfWeek

First day of the week. Default uses the current culture.

[ExCategory(CategoryType.Behavior)]
[ExDescription("First day of the week. Default uses the current culture.")]
public Day FirstDayOfWeek { get; set; }

Property Value

Day

ForeColor

Gets or sets the foreground color of the control.

public override Color ForeColor { get; set; }

Property Value

Color

The foreground Color of the control. The default is the value of the DefaultForeColor property.

HeaderForeColor

Color of the month/year header text.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the month/year header text.")]
public Color HeaderForeColor { get; set; }

Property Value

Color

HighlightColor

Background color of the selected day.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Background color of the selected day.")]
public Color HighlightColor { get; set; }

Property Value

Color

HighlightForeColor

Text color of the selected day.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Text color of the selected day.")]
public Color HighlightForeColor { get; set; }

Property Value

Color

HoverBackColor

Background color of the day or arrow under the mouse.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Background color of the day or arrow under the mouse.")]
public Color HoverBackColor { get; set; }

Property Value

Color

MaxDate

Gets or sets the maximum selectable date; a selected date after it is moved to it.

[ExCategory(CategoryType.Behavior)]
[ExDescription("Maximum selectable date.")]
public DateTime MaxDate { get; set; }

Property Value

DateTime

Exceptions

ArgumentOutOfRangeException

when the date is before MinDate.

MinDate

Gets or sets the minimum selectable date; a selected date before it is moved to it.

[ExCategory(CategoryType.Behavior)]
[ExDescription("Minimum selectable date.")]
public DateTime MinDate { get; set; }

Property Value

DateTime

Exceptions

ArgumentOutOfRangeException

when the date is after MaxDate.

SelectionDate

Selected date (time part is ignored).

[ExCategory(CategoryType.Behavior)]
[ExDescription("Selected date.")]
[Bindable(true)]
public DateTime SelectionDate { get; set; }

Property Value

DateTime

ShowToday

Shows the "Today" line at the bottom of the calendar.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Shows the Today line at the bottom of the calendar.")]
public bool ShowToday { get; set; }

Property Value

bool

ShowWeekNumbers

Shows week numbers in the first column.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Shows week numbers in the first column.")]
public bool ShowWeekNumbers { get; set; }

Property Value

bool

TodayBorderColor

Color of the frame around today's date.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the frame around today's date.")]
public Color TodayBorderColor { get; set; }

Property Value

Color

TodayDate

Date treated as "today". When not set, Today is used.

[ExCategory(CategoryType.Behavior)]
[ExDescription("Date treated as today. When not set, the system date is used.")]
public DateTime TodayDate { get; set; }

Property Value

DateTime

TodayText

Label shown before today's date in the "Today" line.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Label shown before today's date in the Today line.")]
public string TodayText { get; set; }

Property Value

string

TrailingForeColor

Color of the days that belong to the previous or next month.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the days that belong to the previous or next month.")]
public Color TrailingForeColor { get; set; }

Property Value

Color

View

Current view: days of a month, months of a year, years of a decade or decades of a century. Clicking the header switches to the next coarser view, clicking an item goes back down.

[Browsable(false)]
public ExCalendarView View { get; set; }

Property Value

ExCalendarView

WeekNumberForeColor

Color of the week numbers.

[ExCategory(CategoryType.Appearance)]
[ExDescription("Color of the week numbers.")]
public Color WeekNumberForeColor { get; set; }

Property Value

Color

Methods

ApplyTheme(ExTheme)

Sets the colors and appearance of the control by the theme.

public void ApplyTheme(ExTheme theme)

Parameters

theme ExTheme

Dispose(bool)

Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

EnsureVisible(DateTime)

Scrolls the calendar so that the month of the date is visible.

public void EnsureVisible(DateTime date)

Parameters

date DateTime

date to show

GetPreferredSize(Size)

Retrieves the size of a rectangular area into which a control can be fitted.

public override Size GetPreferredSize(Size proposedSize)

Parameters

proposedSize Size

The custom-sized area for a control.

Returns

Size

An ordered pair of type Size representing the width and height of a rectangle.

HitTestDate(Point)

Returns the date at the specified client point, or null when there is no day.

public DateTime? HitTestDate(Point pt)

Parameters

pt Point

point in client coordinates

Returns

DateTime?

IsInputKey(Keys)

Determines whether the specified key is a regular input key or a special key that requires preprocessing.

protected override bool IsInputKey(Keys keyData)

Parameters

keyData Keys

One of the Keys values.

Returns

bool

true if the specified key is a regular input key; otherwise, false.

OnDateChanged(EventArgs)

Raises the DateChanged event.

protected virtual void OnDateChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnDateSelected(EventArgs)

Raises the DateSelected event.

protected virtual void OnDateSelected(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnDefaultStyleChanged()

Raises the DefaultStyleChanged event.

protected virtual void OnDefaultStyleChanged()

OnDisplayMonthChanged(EventArgs)

Raises the DisplayMonthChanged event.

protected virtual void OnDisplayMonthChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnEnabledChanged(EventArgs)

Raises the EnabledChanged event.

protected override void OnEnabledChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnFontChanged(EventArgs)

Raises the FontChanged event.

protected override void OnFontChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnHandleCreated(EventArgs)

Raises the HandleCreated event.

protected override void OnHandleCreated(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnKeyDown(KeyEventArgs)

Raises the KeyDown event.

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

A KeyEventArgs that contains the event data.

OnMouseDown(MouseEventArgs)

Raises the MouseDown event.

protected override void OnMouseDown(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseLeave(EventArgs)

Raises the MouseLeave event.

protected override void OnMouseLeave(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Raises the MouseMove event.

protected override void OnMouseMove(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseWheel(MouseEventArgs)

Raises the MouseWheel event.

protected override void OnMouseWheel(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnPaint(PaintEventArgs)

Raises the Paint event.

protected override void OnPaint(PaintEventArgs e)

Parameters

e PaintEventArgs

A PaintEventArgs that contains the event data.

OnResize(EventArgs)

Raises the Resize event.

protected override void OnResize(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

RescaleConstantsForDpi(int, int)

Provides constants for rescaling the control when a DPI change occurs.

protected override void RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNew)

Parameters

deviceDpiOld int

The DPI value prior to the change.

deviceDpiNew int

The DPI value after the change.

SelectToday()

Selects today's date and raises DateSelected.

public void SelectToday()

SetBoundsCore(int, int, int, int, BoundsSpecified)

Performs the work of setting the specified bounds of this control.

protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)

Parameters

x int

The new Left property value of the control.

y int

The new Top property value of the control.

width int

The new Width property value of the control.

height int

The new Height property value of the control.

specified BoundsSpecified

A bitwise combination of the BoundsSpecified values.

Events

DateChanged

Occurs when SelectionDate changes.

[ExCategory(CategoryType.Action)]
[ExDescription("Occurs when the SelectionDate property changes.")]
public event EventHandler? DateChanged

Event Type

EventHandler

DateSelected

Occurs when the user picks a date (mouse click, Enter or the Today line).

[ExCategory(CategoryType.Action)]
[ExDescription("Occurs when the user picks a date with the mouse or keyboard.")]
public event EventHandler? DateSelected

Event Type

EventHandler

DefaultStyleChanged

Occurs when the DefaultStyle property changes.

[ExCategory("Changed Property")]
[ExDescription("Occurs when the DefaultStyle property changes.")]
public event EventHandler? DefaultStyleChanged

Event Type

EventHandler

DisplayMonthChanged

Occurs when DisplayMonth changes.

[ExCategory(CategoryType.Action)]
[ExDescription("Occurs when the displayed month changes.")]
public event EventHandler? DisplayMonthChanged

Event Type

EventHandler