Date Picker
A date field with a drop-down month calendar, in the manner of Outlook's date pickers: the user types a date, picks one from the calendar, or steps it with the keyboard – for order dates, due dates, dates of birth.
Assembly
| Assembly | Binarymission.WinForms.Controls.BinaryDatePicker.dll |
| Root namespace | Binarymission.WinForms.Controls.DateTimeControls |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
| Depends on | BinaryExtendedText, BinaryToolTip |
Overview
What it is for
The control is a text box and a drop-down button. The text is free text written in Format
(the long date by default) or CustomFormat, and is read back as the user types. It also
understands today, yesterday, tomorrow, one week from now and
one week before now, and names of your own from an XML file (CustomDateXMLFeed).
Keyboard and menu
In the text: Enter commits what was typed, Up and Down move the date a month, Page Up and Page Down a
year, Ctrl+A and Ctrl+S a day forward and back, and Ctrl+L (with the menu on) opens the calendar. In the calendar: the arrows move a
day or a week, Page Up and Page Down a month, Home and End to the ends of the month, Enter chooses and Escape
closes. The right-click menu (ShowCustomMenu) adds clipboard commands and quick dates.
The value
Value is an object: a DateTime, or – with no date
(ValueIsNull) – NullDateString, or DBNull when the control is data
bound. MinValue and MaxValue limit it. BinaryDateChanged reports each
change.
Appearance
The text box's border is set by EditControlStyleIsExtended, BorderColor and
DrawBorderAs; the button by UseDropDownImageStyle; the calendar by the
Calendar..., Selection... and Today... colours, SpecialDates and
Font, from which it is sized.
Getting started
using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.DateTimeControls;
var dueDate = new BinaryDatePicker
{
Location = new Point(16, 16),
Width = 220,
Format = BinaryDatePickerFormat.Custom,
CustomFormat = "ddd dd MMM yyyy",
MinValue = DateTime.Today,
NullDateString = "No due date",
SpecialDates = new[] { new DateTime(2026, 12, 25), new DateTime(2026, 12, 26) }
};
dueDate.Value = DateTime.Today.AddDays(30);
dueDate.BinaryDateChanged += (sender, e) =>
invoice.DueDate = dueDate.ValueIsNull ? (DateTime?)null : (DateTime)dueDate.Value;
invoiceForm.Controls.Add(dueDate);API reference
Binarymission.WinForms.Controls.DateTimeControls
class BinaryDatePicker | A date field with a drop-down month calendar, in the manner of Outlook's date pickers: the user types a date, picks one from the calendar, or steps it with the keyboard - for order dates, due dates, dates of birth. |
delegate CustomFormatDateChangeHandler | Represents the method that handles CustomFormatDateChanged. |
delegate CustomValidator | Represents the method that handles UserDateCustomValidating. |
delegate DateChangePreHandler | Represents the method that handles BinaryDateAboutToBeChanged. |
delegate MouseOverADateHandler | Represents the method that handles MouseIsOverADate. |
enum BinaryDatePickerFormat | Specifies the format a BinaryDatePicker writes its date in. |
enum BinaryToolTipStyle | Specifies the shape of a tooltip shown for a day in a BinaryDatePicker's calendar. |
enum BorderState | Specifies how the border of a BinaryDatePicker's text box is drawn. |
class DateInfo | Describes the day under the pointer in the calendar, for MouseIsOverADate. |
class DateToolTipInfo | The tooltip to show for a day in the calendar, filled in by a MouseIsOverADate handler. |
enum DropDownImageStyle | Specifies what a BinaryDatePicker draws on its drop-down button. |