AdvancedDateTimePicker Class

Represents a date-time picker control with additional features such as adjustable colors, fixed rendering in high DPI mode, and more.

See the online help for an image example.

Definition

Namespace: KGySoft.WinForms.Controls
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public class AdvancedDateTimePicker : DateTimePicker
Inheritance
Object    MarshalByRefObject    Component    Control    DateTimePicker    AdvancedDateTimePicker

Remarks

The DateTimePicker control offers the following features in addition to DateTimePicker:
  • Adjustable colors when the control is not focused (or visual styles are disabled).
  • Its Value property is redefined so it returns MaxValue if Checked is and instead of throwing exception when invalid date is assigned to it, it simpy changes Checked false (if checkbox is visible), or just ignores the value.
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled (see AutoScaleFont). Note that it affects font scaling only, so auto-sizing behavior still depends on the current platform.
  • When rendering with visual styles on high DPI, preferring always the standard check box sizes. When the standard size cannot be used, improving the rendering quality if CheckBoxRenderingQuality is High.

Examples

The following image illustrates a few features of the AdvancedDateTimePicker class, like the default disabled colors difference, and the fixed checkbox rendering on high DPI (the example uses 125% scaling on Windows 11):

AdvancedComboBox in the KGySoft.WinForms.Example application

  Tip

The image above is from the example application. At the Releases page of the project repository you can download it as executable binaries as well.

Constructors

AdvancedDateTimePicker Creates a new AdvancedDateTimePicker instance.

Properties

AutoScaleFont Gets or sets whether the Font should be automatically scaled when DPI changes and the current thread has per-monitor DPI awareness.
Default value: .
BackColor Gets or sets the background color of the control in the current Enabled and Checked state.
(Overrides DateTimePicker.BackColor)
CheckBoxRenderingQuality Gets or sets the rendering quality of the checkbox visuals when ShowCheckBox is , and visual styles are enabled.
DisabledBackColor Gets or sets the background color when the control is not Enabled.
DisabledForeColor Gets or sets the text color when the control is not Enabled.
EnabledBackColor Gets or sets the background color when the control is Enabled.
EnabledForeColor Gets or sets the text color when the control is Enabled.
FontGets or sets the font of the text displayed by the control.
(Overrides ControlFont)
ForeColor Gets or sets the foreground color of the control in the current Enabled and Checked state.
(Overrides DateTimePicker.ForeColor)
Value Gets or sets the date/time value assigned to the control.

Methods

DisposeReleases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.
(Overrides ControlDispose(Boolean))
OnCloseUpRaises the CloseUp event.
(Overrides DateTimePickerOnCloseUp(EventArgs))
OnDropDownRaises the DropDown event.
(Overrides DateTimePickerOnDropDown(EventArgs))
OnFontChangedRaises the FontChanged event.
(Overrides DateTimePickerOnFontChanged(EventArgs))
OnGotFocusRaises the GotFocus event.
(Overrides DateTimePickerOnGotFocus(EventArgs))
OnHandleCreatedRaises the HandleCreated event.
(Overrides DateTimePickerOnHandleCreated(EventArgs))
OnLeaveRaises the Leave event.
(Overrides ControlOnLeave(EventArgs))
OnMouseEnterRaises the MouseEnter event.
(Overrides ControlOnMouseEnter(EventArgs))
OnMouseLeaveRaises the MouseLeave event.
(Overrides ControlOnMouseLeave(EventArgs))
OnMouseMoveRaises the MouseMove event.
(Overrides ControlOnMouseMove(MouseEventArgs))
OnParentChangedRaises the ParentChanged event.
(Overrides ControlOnParentChanged(EventArgs))
OnParentFontChangedRaises the FontChanged event when the Font property value of the control's container changes.
(Overrides ControlOnParentFontChanged(EventArgs))
OnSizeChangedRaises the SizeChanged event.
(Overrides ControlOnSizeChanged(EventArgs))
WndProcProcesses Windows messages.
(Overrides DateTimePickerWndProc(Message))

Extension Methods

GetFormatFlags Gets the formatting flags for the text of a custom drawn control.
(Defined by ControlExtensions)
GetScale Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
(Defined by ScaleHelper)
GetScrollBarSize Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
(Defined by ScaleHelper)
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
(Defined by ScaleHelper)
ScaleHeight Scales the specified height by the vertical scale factor of the control.
(Defined by ScaleHelper)
ScaleSize Scales the specified size by the scale factor of the control.
(Defined by ScaleHelper)
ScaleWidth Scales the specified width by the horizontal scale factor of the control.
(Defined by ScaleHelper)
SetControlEnabled Sets the Enabled property of the child controls within the specified root control, or the Enabled property of the specified control itself, if it is not a recognized container control. By this way pages of a TabControl will remain selectable, a SplitContainer remains resizable, etc.
(Defined by ControlExtensions)
SetControlReadonly Recursively sets the read-only state in the children of the specified root control. Affects TextBoxBase and IReadOnlyCapable instances.
(Defined by ControlExtensions)
SetDoubleBuffered Sets the double buffered state of a control
(Defined by ControlExtensions)
SetStyle Sets a specified ControlStyles flag to either or . It calls the protected Control.SetStyle method on the specified control as if it was a public method.
(Defined by ControlExtensions)

See Also