Spinner
A domain up-down box – a list of text items the user steps through with the spin buttons or the arrow keys – with a flat, single-line border and spin buttons in colours you choose.
Assembly
| Assembly | Binarymission.WinForms.Controls.SpinnerControls.dll |
| Root namespace | Binarymission.WinForms.Controls.InputControls |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
What it is for
A drop-in replacement for DomainUpDown, for a short, ordered set of choices such as a
shipping method, a priority or a size, where a drop-down list would be heavier than the choice deserves.
Everything the standard control does – Items, wrapping, sorting, typing to select,
keyboard and accessibility – works unchanged. What it adds is the look: a flat border that lights up in
BorderColor, and spin buttons drawn in three states – resting, hot (under the pointer or holding
the focus) and pressed.
Appearance
DrawStyleIsFlatswitches the flat drawing on (the default) or off, giving back the standard 3D look.ShowBorderAlwayskeeps the border and the buttons in their hot colours at all times (the default). Set it tofalsefor the classic hover effect, where the control rests borderless and lights up under the pointer or with the focus.UpDownButtonNormalBackColor,UpDownButtonOnFocusBackColorandUpDownArrowPressedBackColorcolour the buttons in the three states, andUpDownArrowsColorthe arrows.
The button colours follow the Windows colour scheme until they are set. The spin buttons widen with the font, so a large font or a high display scale keeps them in proportion to the text.
Getting started
A shipping-method picker that cannot be typed into, and shows the delivery estimate for the choice.
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.InputControls;
var estimate = new Label { Location = new Point(190, 19), AutoSize = true };
var shipping = new BinaryDomainUpDown
{
Location = new Point(16, 16),
Width = 160,
ReadOnly = true,
Wrap = true,
BorderColor = Color.SeaGreen,
UpDownButtonOnFocusBackColor = Color.Honeydew,
UpDownArrowsColor = Color.DarkGreen
};
shipping.Items.AddRange(new object[] { "Standard", "Express", "Next working day" });
shipping.SelectedIndex = 0;
shipping.SelectedItemChanged += (sender, e) =>
estimate.Text = shipping.SelectedIndex == 0 ? "3-5 days" : shipping.SelectedIndex == 1 ? "2 days" : "Tomorrow";
checkoutForm.Controls.Add(shipping);
checkoutForm.Controls.Add(estimate);API reference
Binarymission.WinForms.Controls.InputControls
class BinaryDomainUpDown | A domain up-down box - a list of text items the user steps through with the spin buttons or the arrow keys - with a flat, single-line border and spin buttons in colours you choose. |
class BinaryNumericUpDown | A numeric up-down box with a flat, single-line border and spin buttons in colours you choose - for quantities, prices, percentages and any other number the user types or steps through. |