HypernovaDesktop Components · docs
Binarymission
WinForms › Time Picker

Time Picker

.NET Framework 4.8.NET 6 / 8 / 10v3.1.0WinForms

A time field with a drop-down of spin columns – hours, minutes, seconds and AM/PM – for picking a time of day: an appointment, a delivery slot, a shift start.

4public types
141public members
1namespaces

Assembly

AssemblyBinarymission.WinForms.Controls.AdvancedSelectors.dll
Root namespaceBinarymission.WinForms.Controls.Selectors
Target frameworks.NET Framework 4.8, .NET 6 / 8 / 10
Depends onDoubleBufferedControlBase, PopupEditor

Overview

What it is for

The control shows the time as text, with a button beside it. The button opens a drop-down holding a column for each part of the time, each with an up arrow, the value and a down arrow. The user clicks the arrows, holds them down or turns the mouse wheel over them, and the text follows every change. The drop-down closes when the user clicks elsewhere, and can be resized by its bottom edge.

How to use it

Appearance

The colours of the arrows, the value boxes and the column backgrounds are properties of this control. The look of the text field, the drop-down button and the drop-down window – fonts, borders, size, resize strip – is in DropDownHostConfiguration. The drop-down's parts read their settings when it is first created, so set the appearance before it first opens.

Getting started

A collection-time picker on a booking form, on the twenty-four-hour clock without seconds.

using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Selectors.TimeSelectors;

var collectionTime = new TimePickerDropDown
{
    Location = new Point(16, 16),
    Size = new Size(180, 32),
    TimeConvention = TimeConvention.TwentyFourHours,
    TwentyFourHoursTimeDisplayFormat = "HH:mm",
    SpinnerBackgroundBrushStartColor = Color.SteelBlue,
    SpinnerHoverBackgroundBrushStartColor = Color.DodgerBlue,
    SpinnerPressedBackgroundBrushStartColor = Color.Navy
};

collectionTime.TimeValue = DateTime.Today.AddHours(9).AddMinutes(30);
collectionTime.DropDownHostConfiguration.PopupCommandVisualNormalBackColor = Color.SteelBlue;
collectionTime.DropDownHostConfiguration.PopupCommandVisualBorderColor = Color.SteelBlue;

collectionTime.DropDownViewOpened += (sender, e) => statusLabel.Text = "Choose a collection time";

bookingForm.Controls.Add(collectionTime);

API reference

Binarymission.WinForms.Controls.Selectors.TimeSelectors

class DropDownHostConfigurationThe look and behaviour of a TimePickerDropDown's text field, its drop-down button and the drop-down window: fonts, colours, borders, the drop-down's size and position, and its resize strip.
interface ITimePickerHostThe settings a time picker's drop-down reads from the control that hosts it: the step and repeat rate of the arrows, the fonts and colours of the columns, and the time itself.
enum TimeConventionSpecifies the clock a TimePickerDropDown shows and picks times on.
class TimePickerDropDownA time field with a drop-down of spin columns - hours, minutes, seconds and AM/PM - for picking a time of day: an appointment, a delivery slot, a shift start.