HeaderPane
Main

Compare

A Windows Forms ComboBox with columns

The Windows Forms ComboBox lists one column of text. Columns, images, a hierarchy or check boxes in its list all have to be drawn by your own code, and typing finds items only by the start of their text. Here is how the ComboBox, plain and owner-drawn, compares with SftBox/NET 3.0.

The problem

The ComboBox is fine for picking one string from a short list. It runs out as soon as an item needs more than its name: a customer with a city and an account number, a product with its price, a country with its flag. Its list has one column, so the usual workaround is DrawMode.OwnerDrawFixed and a DrawItem handler that paints the columns, with no column headers and widths that your code has to work out.

More gaps show up as the lists grow. Categories cannot be grouped under expandable parents. Typing finds items only by the start of their text, never by a word inside it, and the list cannot be narrowed to the matching items. The dropdown has a fixed width that your code sets, and a DropDownList combo box shows the selected item as a single string.

SftBox/NET 3.0 is a combo box for Windows Forms, written entirely in C#, whose list is a multi-column tree, with these features built in.

Feature comparison

FeatureComboBoxOwner-drawn ComboBoxSftBox/NET 3.0
Columns in the listNo, one column of textPainted by your DrawItem code, without headersColumns with headers and footers, grid lines and sorting
HierarchyNoIndentation painted by your code, nothing to expand or collapseExpand/collapse buttons, tree lines and item images
Images, check boxes, progress barsNoPainted by your code, with no mouse handlingBuilt in, in any cell, with buttons and radio buttons too
Searching as the user typesBy the start of the textBy the start of the textPrefix, exact, auto-complete, contains, or a filter that shows only the matching items with their parent items, in any column
The selected item in a DropDownListIts textPainted by your codeThe item as the list shows it, with all its columns and images
Dropdown sizeA width your code setsA width your code setsAs wide as all columns, aligned with either edge, above or below the control, resizable by the user
Clear buttonNoNoYes
Data bindingDataSource, DisplayMember, ValueMemberDataSource, DisplayMember, ValueMemberThe same, with a column for each data member and a hierarchy from keys or child lists
Font listsNames added by your code, in the control's fontPainted by your codeEach name in its own font, plus lists of styles and sizes

What the code looks like

If you know the ComboBox, much of SftBox/NET will look familiar: DataSource, DisplayMember, ValueMember, SelectedValue, Text and DroppedDown. It is not a drop-in replacement, though: the list is a tree with items, columns and cells, and the selection is an item rather than an index. This binds a combo box to a table of countries with two columns, filters the list as the user types, shows a placeholder while nothing is selected, and binds the selected country to an order as a lookup field:

sftBox1.Columns.Count = 2;
sftBox1.Columns[0].DataMember = "Name";
sftBox1.Columns[1].DataMember = "Capital";
sftBox1.DropDownWidthMode = DropDownWidthModeEnum.Optimal;
sftBox1.DisplayMember = "Name";
sftBox1.ValueMember = "Id";
sftBox1.DataSource = countries;

sftBox1.SearchMode = SearchModeEnum.Filter;
sftBox1.Placeholder = "Select a country";
sftBox1.ShowClearButton = true;

sftBox1.DataBindings.Add("SelectedValue", order, "CountryId",
    false, DataSourceUpdateMode.OnPropertyChanged);

You can also skip most of the code: the control is placed from the Visual Studio toolbox, and its property pages set up the combo box and its list visually. The documentation lists where each ComboBox function is found in SftBox/NET.

Modern Windows

SftBox/NET 3.0 runs in .NET Framework 4.7 (or later) and .NET 10 (or later) applications, with the same API and Visual Studio designer support in both. Set one property and the combo box and its dropdown follow the Windows light/dark setting. The control scales with the DPI of the monitor showing it, honors the Windows contrast themes and has built-in UI Automation support for Narrator, NVDA, JAWS and other screen readers.

When the ComboBox is enough

If a form needs one string picked from a short, flat list, the ComboBox is fine, and it is free. SftBox/NET earns its place when items have more than a name, when lists are long enough that users search them, when choices fall into groups, or when the selected item should look the way it looks in the list.

Try it

The free trial includes the working control and the C# and VB.NET samples. Test it in your own forms before you buy. A license is royalty-free and includes one year of support and upgrades.

SftBox/NET 3.0 and free trial Documentation