HypernovaDesktop Components · docs
Binarymission
WinForms › Combo Box › BinaryTextComboBox

BinaryTextComboBox

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.ListControls

A text combo box that adds auto-completion, a read-only mode, and a multi-column drop-down that can sort, filter, group and export the rows of a data source – the Hypernova combo box for picking a record by its name.

public partial class BinaryTextComboBox : BinaryComboBox, IMessageFilter

Inherits from / implements: BinaryComboBox, IMessageFilter

Remarks

What it is for

Use it wherever a standard ComboBox would do and you want more: an account, a product or a customer chosen from a table, with every useful column on show while the user picks, and the chosen record's key in SelectedValue. It keeps the framework combo box's list, binding and keyboard behaviour, and adds the flat painting and colours of BinaryComboBox. For an image beside each item use BinaryImageComboBox.

Single-column use

Fill ComboBox.Items, or bind DataSource with DisplayMember and ValueMember, exactly as for a ComboBox. As the user types, AutoComplete completes the text from the first item that starts with it; EnforceItemsInList and the NotInList event catch text that matches no item.

The multi-column drop-down

Set DropStyleIsMultiColumn and bind DataSource – a DataTable, DataView, DataSet (with DataMember) or a list of objects. The button then opens a resizable window listing every column (or the ones in ColumnsToDisplay, headed by HeadersToDisplay). The user picks a row with a double-click (ItemSelectionClick) or Enter; its DisplayMember value becomes the text, its ValueMember value SelectedValue, and its index SelectedIndexFromDropList. Clicking a heading sorts (EnableColumnSorting), the right-click menu groups the rows and exports them to a CSV file, and an options pane (ShowFilterOptionsInMultiColumnMode) filters them as the user types. The window opens sized to its columns, below the control or above it where there is more room, and remembers a size the user drags it to in MultiColumnDropDownSize.

Appearance

The drop-down's colours and font are the MultiColumnDropList properties; its optional header and footer band is set up through MultiColumnDropDownWindowConfigurationData and EnableDrawingHeaderFooterWhenInMultiColumnMode; every caption it shows can be translated through MultiColumnViewUIElementsTextProvider. The control's own face is flat while DisplayStyleIsFlat is on, which by default follows whether Windows visual styles are on.

Examples

An account picker that shows the account number, name, city and balance of each customer, and puts the chosen account number in SelectedValue.

var customers = new DataTable("Customers");
customers.Columns.Add("AccountNo", typeof(string));
customers.Columns.Add("Name", typeof(string));
customers.Columns.Add("City", typeof(string));
customers.Columns.Add("Balance", typeof(decimal));
customers.Rows.Add("AC-1001", "Harper Logistics", "Leeds", 12450.00m);
customers.Rows.Add("AC-1002", "Northwind Foods", "Bristol", 830.50m);
customers.Rows.Add("AC-1003", "Kestrel Print", "York", 4120.75m);

var accountPicker = new BinaryTextComboBox
{
    Location = new Point(12, 12),
    Width = 260,
    DropStyleIsMultiColumn = true,
};
accountPicker.DataSource = customers;
accountPicker.DisplayMember = "Name";
accountPicker.ValueMember = "AccountNo";
accountPicker.ColumnsToDisplay = new[] { "AccountNo", "Name", "City", "Balance" };
accountPicker.HeadersToDisplay = new[] { "Account", "Customer", "City", "Balance" };
accountPicker.MultiColumnWindowColumnsHorizontalAlignments = new List<HorizontalAlignment>
{
    HorizontalAlignment.Left, HorizontalAlignment.Left, HorizontalAlignment.Left, HorizontalAlignment.Right
};

accountPicker.SelectedIndexChanged += (sender, e) =>
    Text = "Account " + accountPicker.SelectedValue + " - " + accountPicker.Text;

Controls.Add(accountPicker);

See also

Members at a glance

Constructors
BinaryTextComboBoxInitialises a new text combo box in DropDown style, with auto-completion on.
Properties
AlphaBlendingfactorForFilterAndGroupingPanelBackColorGets or sets how strongly the pane colour shows when the filter and grouping pane's colour is blended with the window colour.
AnimateDropDownWindowGets or sets whether the multi-column drop-down animates as it closes after the user picks a row.
AnimationIntervalGets or sets the pause between the steps of the multi-column drop-down's closing animation.
AutoCompleteGets or sets whether the text the user types is completed from the first item that starts with it.
AutoCompleteBasedOnCompleteMatchWithAnItemInTheListGets or sets which item the control's auto-completion uses when several start with the typed text: the first, or the last.
AutoCompleteIsCaseSensitiveGets or sets whether the control's auto-completion, and its check for text that is not in the list, tell upper and lower case apart.
AutoCompleteModeGets or sets the framework's auto-completion mode, used in place of the control's own completion.
AutoCompleteStyleForMultiColumnModeIsMultiColumnGets or sets whether, in multi-column mode, the user's typing opens a multi-column suggestion list under the control in place of the ordinary text completion.
BuiltinFilterOnNonStringTypeColumnFilterModeGets or sets how the built-in filter of the multi-column drop-down matches a column that holds numbers, dates or other values that are not text.
BuiltinFilterOnStringTypeColumnFilterModeGets or sets how the built-in filter matches a column that holds text. The setting is stored but not used.
BusyIndicatorTextGets or sets the text shown in the control's text area while the multi-column drop-down is being built.
CSVFileSaveAsGets or sets the file the multi-column drop-down's "Export data to CSV" command writes to.
ColumnDataTypeFormatInfoContainersGets or sets how the values in each column of the multi-column drop-down are formatted – dates, currency, decimals or thousands separators.
ColumnWidthsGets or sets the width of each column of the multi-column drop-down, in place of the widths it works out from the content.
ColumnsToDisplayGets or sets which columns of the data source the multi-column drop-down shows, and in what order.
ComboBoxIsReadOnlyGets or sets whether the user is prevented from typing in the control's text area, while still being able to select and copy its text.
CustomColumnNameForAutomaticRowSelectionGets or sets the column the multi-column drop-down searches when the user types a letter or digit in it, jumping to the next row whose value in that column starts with that character.
CustomComparerImplementorGets or sets a comparison of your own for sorting the rows of the multi-column drop-down.
CustomDropDownWindowLocationPointGets or sets a fixed screen position for the top-left corner of the multi-column drop-down.
CustomPaintingColorGets or sets the accent colour the control blends to fill its drop-down button and the highlighted item; the multi-column drop-down takes its accents from it too.
DataMemberGets or sets the table of a DataSet data source that the multi-column drop-down lists.
DataSourceGets or sets the data the control lists: a DataTable, DataView, DataSet, a BindingSource, or any list of objects.
DataSourceViewCustomSortingExpressionGets or sets a sort expression that orders the rows of the multi-column drop-down, such as "City ASC, Name ASC".
DesiredFilterColumnGets or sets the column the built-in filter of the multi-column drop-down starts on.
DisplayMemberGets or sets the column or property of the data source whose value the control shows as the item's text.
DisplayStyleIsFlatGets or sets whether the control is drawn with its own flat look – the border, button and colours of BinaryComboBox – rather than as a standard Windows combo box.
DrawTheControlBasedOnWindowsOSGets or sets whether the control decides for itself between its flat look and the standard Windows look, by whether Windows visual styles are on.
DropDownWindowBackgroundColorGets or sets the background colour of the drop-down list, in both single-column and multi-column mode.
DropDownWindowDisplayOrientationGets or sets which way the multi-column drop-down extends from the control: to the right of its left edge, or to the left of its right edge.
DropStyleIsMultiColumnGets or sets whether the drop-down button opens a multi-column window listing every column of the data source, instead of the ordinary single-column list.
DroppedDownGets or sets whether the drop-down is open; setting it to true opens the multi-column drop-down, or the ordinary list.
EnableAlphaBlendingForFilterAndGroupingPanelBackColorGets or sets whether the filter and grouping pane's colour is blended with the window colour into a paler tint.
EnableColumnSortingGets or sets whether the user can sort the multi-column drop-down by clicking a column heading.
EnableDrawingHeaderFooterWhenInMultiColumnModeGets or sets whether the multi-column drop-down is framed by a header band and a footer band, set up in MultiColumnDropDownWindowConfigurationData.
EnableUserColumnResizingGets or sets whether the user can drag the edges of the multi-column drop-down's column headings to resize the columns.
EnforceItemsInListGets or sets whether the control checks the text the user types against its list, raising NotInList when it matches no item.
FilterAndGroupingPanelBackColorGets or sets the background colour of the multi-column drop-down's filter and grouping pane.
FilteringIsONGets or sets whether filtering is switched on in the multi-column drop-down's options pane when the drop-down opens.
GroupItemsWhenInMultiColumnDisplayModeGets or sets whether the multi-column drop-down opens with its rows grouped under headings, one for each different value in a column.
GroupMultiColumnDisplayModeDataBasedOnThisColumnGets or sets the column the multi-column drop-down groups its rows by.
HeadersToDisplayGets or sets the heading text of each column of the multi-column drop-down, in place of the column names.
IsAutoCompleteModeAppendSuggestInMultiColumnModeGets or sets whether the multi-column suggestion list also fills in the rest of the first matching item's text, the way SuggestAppend does.
IsCustomisationOfColumnDisplayEnabledInMultiColumnAutoSuggestModeGets or sets whether the multi-column suggestion list shows only the columns in ColumnsToDisplay, rather than every column of the data source.
IsFilterSearchResultBasedOnColumnDataTypeGets or sets whether the formats in ColumnDataTypeFormatInfoContainers also set the type each column is filtered as, so the built-in filter compares numbers and dates by value.
IsSourceDataPreSortedGets or sets whether the data source is already in the order the multi-column drop-down should show, so the list does not sort it again.
ItemSelectionClickGets or sets whether the user picks a row of the multi-column drop-down with a single click or a double-click.
KeepBindingContextInSyncWithParentGets or sets whether the multi-column combo box moves the current record of the form's data binding when the user picks a row, and follows it when the form moves it.
KeepTheFilterAndGroupingViewsCollapsedAtStartUpGets or sets whether the filter and grouping sections of the multi-column drop-down's options pane open folded to their title lines.
KeepTheFilterAndGroupingViewsPaneFullyCollapsedAtStartupGets or sets whether the multi-column drop-down opens with its filter and grouping pane hidden, leaving only the button that shows it.
MultiColumnDefaultGroupedModeGroupSortingOrderGets or sets the order of the group headings when the multi-column drop-down opens with its rows grouped.
MultiColumnDropDownSizeGets or sets the size of the multi-column drop-down window, in logical pixels.
MultiColumnDropDownWindowConfigurationDataGets or sets the settings for the multi-column drop-down's header and footer bands, its column headings, and its no-data message.
MultiColumnDropListBackColorGets or sets the background colour of the rows in the multi-column drop-down.
MultiColumnDropListFontGets or sets the font of the rows in the multi-column drop-down.
MultiColumnDropListForeColorGets or sets the colour of the text in the rows of the multi-column drop-down.
MultiColumnDropListGridLinesGets or sets whether lines are drawn between the rows and columns of the multi-column drop-down.
MultiColumnDropListHoverSelectionGets or sets whether a row of the multi-column drop-down is highlighted when the pointer rests on it, without a click.
MultiColumnDropListWindowIsResizableGets or sets whether the user can resize the multi-column drop-down by dragging its edges.
MultiColumnDroplistWindowAnimationStyleGets or sets how the multi-column drop-down animates as it closes after the user picks a row.
MultiColumnModeSourceDataSortedColumnIndexGets or sets the column the multi-column drop-down is sorted by when it opens.
MultiColumnViewBusyProcessingTextGets or sets the message the multi-column drop-down shows while it rebuilds its rows – when the user filters or groups them.
MultiColumnViewNoDataFoundTextGets or sets the message the multi-column drop-down shows when a filter leaves no rows.
MultiColumnViewSortingGlyphColorGets or sets the colour of the arrow drawn in the heading of the column the multi-column drop-down is sorted by.
MultiColumnViewUIElementsTextProviderGets or sets the captions, messages and menu text the multi-column drop-down shows, so they can be translated.
RaiseNotInListWhenTypingGets or sets whether NotInList is raised as the user types, rather than only when they leave the control.
SelectedIndexFromDropListGets or sets the position, in the data source, of the row picked in the multi-column drop-down.
SelectedValueGets or sets the ValueMember value of the selected item – typically the key of the record the user picked.
ShareCustomMultiColumnSizeAcrossDataListAndFilterGroupingOptionsPaneGets or sets whether the multi-column drop-down keeps its size when the user shows or hides the filter and grouping pane, the pane taking its room from the list.
ShouldAllowDragDropOfColumnsGets or sets whether the user can drag the multi-column drop-down's column headings to change the order of the columns.
ShouldAllowUserInputWhileProcessingMultiColumnAutoCompleDropDownViewGets or sets whether the user can go on typing while the multi-column suggestion list is open.
ShouldPersistUserSetColumnWidthsAcrossFilterSessionsGets or sets whether the column widths the user has set in the multi-column drop-down are kept when a filter is applied or cleared.
ShowDropDownMultiColumnWindowAfterAdjustingForVirtualAvaliableScreenSpaceGets or sets whether the multi-column drop-down is moved and, if need be, shortened so that it fits on the screen.
ShowEmptyDropListViewWhenThereAreNoDataGets or sets whether the drop-down opens when there is nothing to list.
ShowFilterOptionsInMultiColumnModeGets or sets whether the multi-column drop-down has a filter and grouping pane at its foot, for the user to filter and group the rows.
SizeForMultiColumnAutoCompleteSuggestionDropDownWindowGets or sets the size of the multi-column suggestion list.
SizesForMultiColumnAutoCompleteSuggestionDropDownWindowColumnsGets or sets the width of each column of the multi-column suggestion list.
TableToLoadGets or sets the table the multi-column drop-down lists. Kept for older applications; set DataSource instead.
ValueMemberGets or sets the column or property of the data source whose value SelectedValue returns, such as the record's key.
Methods
CloseMultiColumnDropDownListWindowCloses the multi-column drop-down if it is open, without picking a row.
DisposeRemoves the control's application message filter and releases its resources.
GetRowDataStringReturns the text shown for one row of the data source: its DisplayMember value.
GetTheColumnValueReturns the value of one column of one row of the data source, as text – for reading another column of the record the user picked.
MakeBlankClears the selection, so the control shows no item, without raising ComboBox.SelectedIndexChanged.
OnDropDownOpens the drop-down: in multi-column mode it builds and shows the multi-column window; otherwise it raises the ComboBox.DropDown event as usual.
OnKeyDownRaises the Control.KeyDown event after opening the multi-column drop-down for Alt+Down, Alt+Up or F4, when the control is in multi-column mode.
OnKeyUpRaises the Control.KeyUp event and then does the control's typing work: completing the text, checking it for NotInList, and showing the multi-column suggestion list.
OnLeaveRaises the Control.Leave event, then raises NotInList if EnforceItemsInList is on and the text equals no item, and closes the multi-column suggestion list.
OnSelectedIndexChangedRaises the ComboBox.SelectedIndexChanged event after the control's own bookkeeping.
OnTextChangedRaises the Control.TextChanged event, then raises NotInList if the new text cannot lead to an item and RaiseNotInListWhenTyping is on.
PaintControlWithDataDraws one item's text, in the list or on the closed control, over the background the base draws.
PreFilterMessageWatches the application's mouse clicks so that, while the multi-column suggestion list lets the user go on typing, a click outside the list and the control closes it.
RefreshPaintRedraws the selected item's text on the closed control, aligned by BinaryComboBox.TextAlignment.
SetDataDraws the disabled control, with the selected item's text in SystemColors.ControlDark.
WndProcProcesses Windows messages, raising DropDownAboutToBeShown when the user clicks the control or presses Alt+Down, and opening the multi-column drop-down in place of the ordinary list.
Events
AutoCompletingOccurs after each key the user types, just before the control completes the text, and lets the handler skip the completion.
CustomSortingOccurs when the multi-column drop-down is about to sort its rows by a column, so the application can supply its own comparison or cancel the sort.
DropDownAboutToBeShownOccurs when the user is about to open the drop-down – by clicking the control, or pressing Alt+Down, Alt+Up or, in multi-column mode, F4 – and lets the handler stop it.
NotInListOccurs when the text the user typed matches no item in the list, so the application can reject it or add it.

Constructors

BinaryTextComboBox

public BinaryTextComboBox()

Initialises a new text combo box in DropDown style, with auto-completion on.

Remarks

The control registers itself as an application message filter, so it can close its suggestion list when the user clicks elsewhere; disposing the control removes the filter. DrawTheControlBasedOnWindowsOS starts true, so the flat look is used while Windows visual styles are on.

Properties

AlphaBlendingfactorForFilterAndGroupingPanelBackColor

public int AlphaBlendingfactorForFilterAndGroupingPanelBackColor

Gets or sets how strongly the pane colour shows when the filter and grouping pane's colour is blended with the window colour.

Value
A blend weight from 0 to 255: 255 is the pane colour itself, 0 the window colour. The default is 135.
Designer category
Multi-Column data display view
Remarks

AnimateDropDownWindow

public bool AnimateDropDownWindow

Gets or sets whether the multi-column drop-down animates as it closes after the user picks a row.

Value
true to animate. The default is false.
Default
false
Remarks
Example
productPicker.AnimateDropDownWindow = true;
productPicker.MultiColumnDroplistWindowAnimationStyle = MultiColumnDroplistWindowAnimationStyle.Vanish;
productPicker.AnimationInterval = 20;   // about a fifth of a second in all

AnimationInterval

public int AnimationInterval

Gets or sets the pause between the steps of the multi-column drop-down's closing animation.

Value
The pause in milliseconds. The default is 100. 0 turns the animation off.
Default
100
Remarks

The vanish animation takes nine steps; the resize animation about one step for every 11 pixels of the window's height. The user waits for the whole animation, so keep the pause short.

AutoComplete

public bool AutoComplete

Gets or sets whether the text the user types is completed from the first item that starts with it.

Value
true to complete the text. The default is true.
Remarks

Works in DropDown style. After each key the control finds the first item whose text starts with what has been typed – matching case as AutoCompleteIsCaseSensitive says – fills in the rest, selected so the next key replaces it, and, when ValueMember is set, sets SelectedValue to that item's value. The AutoCompleting event comes first and can skip it.

This completion runs while AutoCompleteMode is None; choose another mode to use the framework's completion instead. Turning this property off turns both off, and turning it back on restores the mode that was set.

In multi-column mode, AutoCompleteStyleForMultiColumnModeIsMultiColumn shows the matching rows in a suggestion list as the user types.

See also

AutoCompleteBasedOnCompleteMatchWithAnItemInTheList

public bool AutoCompleteBasedOnCompleteMatchWithAnItemInTheList

Gets or sets which item the control's auto-completion uses when several start with the typed text: the first, or the last.

Value
false (the default) to complete from the first matching item in list order; true to complete from the last.
Remarks

The NotInList check searches the list the same way. Not shown in the Properties window.

AutoCompleteIsCaseSensitive

public bool AutoCompleteIsCaseSensitive

Gets or sets whether the control's auto-completion, and its check for text that is not in the list, tell upper and lower case apart.

Value
true to match case exactly. The default is true.
Remarks

Set it to false so that typing "lee" completes to "Leeds". It applies to the completion done by AutoComplete and to the matching behind NotInList; the framework's own AutoCompleteMode completion ignores case anyway. Not shown in the Properties window.

AutoCompleteMode

public new AutoCompleteMode AutoCompleteMode

Gets or sets the framework's auto-completion mode, used in place of the control's own completion.

Value
One of the AutoCompleteMode values. The default is None, which leaves completion to AutoComplete.
Remarks

When the control already has a data source, items or data bindings, setting a mode also sets ComboBox.AutoCompleteSource to ListItems, so the suggestions come from the list. Turning AutoComplete off sets the mode to None, and turning it back on restores the mode set here.

AutoCompleteStyleForMultiColumnModeIsMultiColumn

public bool AutoCompleteStyleForMultiColumnModeIsMultiColumn

Gets or sets whether, in multi-column mode, the user's typing opens a multi-column suggestion list under the control in place of the ordinary text completion.

Value
true for the suggestion list. The default is false.
Remarks

Applies while AutoComplete and DropStyleIsMultiColumn are both true. The list is meant to hold the rows whose DisplayMember value starts with the text typed so far; the user picks one by clicking it. Escape, clearing the text, or leaving the control closes it.

Its columns, size and behaviour are set by IsCustomisationOfColumnDisplayEnabledInMultiColumnAutoSuggestMode, SizeForMultiColumnAutoCompleteSuggestionDropDownWindow, SizesForMultiColumnAutoCompleteSuggestionDropDownWindowColumns, ShouldAllowUserInputWhileProcessingMultiColumnAutoCompleDropDownView and IsAutoCompleteModeAppendSuggestInMultiColumnMode.

BuiltinFilterOnNonStringTypeColumnFilterMode

public BuiltinFilterOnNonStringTypeColumnFilterResultsMode BuiltinFilterOnNonStringTypeColumnFilterMode

Gets or sets how the built-in filter of the multi-column drop-down matches a column that holds numbers, dates or other values that are not text.

Value
BuiltinFilterOnNonStringTypeColumnFilterResultsMode.MatchIsExact (the default) keeps the rows equal to what the user typed; BuiltinFilterOnNonStringTypeColumnFilterResultsMode.MatchIsGreaterThanOrEqualTo keeps the rows at or above it.
Remarks

The user types into the filter pane that ShowFilterOptionsInMultiColumnMode shows. Text columns are matched on what their values start with.

BuiltinFilterOnStringTypeColumnFilterMode

public BuiltinFilterOnNonStringTypeColumnFilterResultsMode BuiltinFilterOnStringTypeColumnFilterMode

Gets or sets how the built-in filter matches a column that holds text. The setting is stored but not used.

Value
A BuiltinFilterOnNonStringTypeColumnFilterResultsMode value. The default is BuiltinFilterOnNonStringTypeColumnFilterResultsMode.MatchIsExact.
Remarks

The built-in filter always keeps the text rows whose value starts with what the user typed, whatever this is set to. Columns that do not hold text follow BuiltinFilterOnNonStringTypeColumnFilterMode.

BusyIndicatorText

public string BusyIndicatorText

Gets or sets the text shown in the control's text area while the multi-column drop-down is being built.

Value
The text. The default is "Processing...".
Remarks

The text the user had is put back once the window is open. A large data source can take a moment to list; the message tells the user something is happening. The control does not report this text through NotInList.

CSVFileSaveAs

public string CSVFileSaveAs

Gets or sets the file the multi-column drop-down's "Export data to CSV" command writes to.

Value
A file path. The default is "MultiColumnDataViewExport.csv", a file of that name in the application's current folder.
Remarks

The user is not asked where to save, so choose the path in advance – a folder the user can write to, such as their documents folder. An existing file is overwritten. An empty value removes the command from the drop-down's shortcut menu.

The export holds the rows the list shows at the time, filtered as they are, with a first line of column names, in the order the columns are shown. Values are separated by commas and are not quoted, so a value that itself contains a comma will split across columns.

Example
string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
customerPicker.CSVFileSaveAs = Path.Combine(documents, "Customers.csv");

ColumnDataTypeFormatInfoContainers

public List<ColumnDataTypeFormatInfoContainer> ColumnDataTypeFormatInfoContainers

Gets or sets how the values in each column of the multi-column drop-down are formatted – dates, currency, decimals or thousands separators.

Value
One entry per column, in the order the columns are shown; null, the default, shows every value as it stands.
Remarks

Each ColumnDataTypeFormatInfoContainer says what kind of value its column holds and gives the format to use: a .NET date format such as "dd MMM yyyy" for dates, or the number of decimal places, such as "2", for decimals and currency. A value that does not parse as that kind is shown as it stands.

Give an entry for every column shown; a column without one is shown empty. When the data source is a list of objects or a DataSet, which the control copies into a table of its own, and IsFilterSearchResultBasedOnColumnDataType is on (the default), give an entry for every property or column of the source: the entries then also set the type each column is filtered as. Set the list before DataSource.

Example
invoicePicker.ColumnDataTypeFormatInfoContainers = new List<ColumnDataTypeFormatInfoContainer>
{
    new ColumnDataTypeFormatInfoContainer { ColumnDataTypeFormat = ColumnDataTypeFormat.Text },
    new ColumnDataTypeFormatInfoContainer
    {
        ColumnDataTypeFormat = ColumnDataTypeFormat.DateAndTimeOrDateOnly,
        CustomFormatForTheColumnDataType = "dd MMM yyyy"
    },
    new ColumnDataTypeFormatInfoContainer
    {
        ColumnDataTypeFormat = ColumnDataTypeFormat.CurrencyFormattedForSpecifiedNumberofDecimalPlaces,
        CustomFormatForTheColumnDataType = "2"
    },
};
invoicePicker.DataSource = invoices;   // InvoiceNo, IssuedOn, Amount

ColumnWidths

public int[] ColumnWidths

Gets or sets the width of each column of the multi-column drop-down, in place of the widths it works out from the content.

Value
Widths in logical pixels (1/96 inch), in the order the columns are shown; or null (the default) to size each column to its widest heading or value.
Designer category
Multi-Column data display view
Remarks

The widths are scaled to the display. Columns beyond the end of the array keep their measured width; a width beyond the last column adds an empty column, so give no more widths than there are columns. When MultiColumnDropDownSize is empty the window sizes itself to these widths.

The user can still drag the column edges unless EnableUserColumnResizing is off.

Example
accountPicker.ColumnsToDisplay = new[] { "AccountNo", "Name", "City", "Balance" };
accountPicker.ColumnWidths = new[] { 80, 200, 110, 90 };

ColumnsToDisplay

public string[] ColumnsToDisplay

Gets or sets which columns of the data source the multi-column drop-down shows, and in what order.

Value
Column names (property names, for a list of objects), or null (the default) to show every column in the source's order.
Designer category
Multi-Column data display view
Remarks

An empty array, or one whose first name is blank, means null. Every name must be a column of the source; a name that is not leaves the drop-down empty.

The headings are the column names unless HeadersToDisplay gives one per column; set this property first, since HeadersToDisplay is checked against it. DisplayMember and ValueMember need not be among the columns shown.

Example
employeePicker.DropStyleIsMultiColumn = true;
employeePicker.DataSource = employees;          // EmployeeId, Surname, Forename, Department, Extension
employeePicker.DisplayMember = "Surname";
employeePicker.ValueMember = "EmployeeId";
employeePicker.ColumnsToDisplay = new[] { "Surname", "Forename", "Department", "Extension" };
employeePicker.HeadersToDisplay = new[] { "Surname", "First name", "Department", "Ext." };
See also

ComboBoxIsReadOnly

public bool ComboBoxIsReadOnly

Gets or sets whether the user is prevented from typing in the control's text area, while still being able to select and copy its text.

Value
true to make the text read-only. The default is false.
Remarks

Applies to DropDown style, which has a text area. Typing, Delete and Backspace are ignored, and the control's shortcut menu is replaced by one with a single Copy command. The user can still pick another item from the list; to stop that too, set BinaryComboBox.IsInExtendedReadOnlyMode.

Turning it off removes the shortcut menu, including one you had assigned to Control.ContextMenu yourself.

CustomColumnNameForAutomaticRowSelection

public string CustomColumnNameForAutomaticRowSelection

Gets or sets the column the multi-column drop-down searches when the user types a letter or digit in it, jumping to the next row whose value in that column starts with that character.

Value
The name of a column of the data source, matched without regard to case; or null (the default) to leave typing to the list's standard behaviour.
Remarks

Pressing the same key again moves on to the next matching row, and after the last one starts from the first again.

The name is looked up among the data source's columns when ColumnsToDisplay is not set; when it is set, or the name is not found, the first column shown is searched.

CustomComparerImplementor

public IComparer CustomComparerImplementor

Gets or sets a comparison of your own for sorting the rows of the multi-column drop-down.

Value
An IComparer that compares two ListViewItem rows, or null (the default) for the built-in comparison.
Remarks

The built-in comparison orders values that read as numbers by their value and everything else as text, ignoring case. A comparer of your own is handed the list's rows: read the cell text from SubItems and keep track of the sort direction yourself.

The value in force when the user clicks a heading is the one used, so it is usually set in a CustomSorting handler. Not shown in the Properties window.

CustomDropDownWindowLocationPoint

public Point CustomDropDownWindowLocationPoint

Gets or sets a fixed screen position for the top-left corner of the multi-column drop-down.

Value
A point in screen coordinates, or Point.Empty (the default) to place the window next to the control.
Remarks

A position set here is used as it is: the window is not moved to fit on the screen, and DropDownWindowDisplayOrientation is not applied. Convert from the form's coordinates with Control.PointToScreen.

Example
// Open the drop-down over the details panel rather than under the combo box.
productPicker.CustomDropDownWindowLocationPoint = detailsPanel.PointToScreen(Point.Empty);

CustomPaintingColor

public new Color CustomPaintingColor

Gets or sets the accent colour the control blends to fill its drop-down button and the highlighted item; the multi-column drop-down takes its accents from it too.

Value
The accent colour. The default is SystemColors.Highlight.
Remarks

Besides what BinaryComboBox.CustomPaintingColor describes, the colour is the start of the gradient behind the multi-column drop-down's column headings, and the default colour of its filter and grouping pane. While MultiColumnDropDownWindowConfiguration.HeaderControlRenderingStartColor is empty it is set to this colour, so the header and footer match.

DataMember

public string DataMember

Gets or sets the table of a DataSet data source that the multi-column drop-down lists.

Value
The name of a table in the data set, or null (the default) for the data set's first table.
Designer category
Multi-Column data display view
Remarks

Used in multi-column mode when DataSource is a DataSet. Setting it while such a data source is bound loads the named table.

Example
supplierPicker.DropStyleIsMultiColumn = true;
supplierPicker.DataMember = "Suppliers";
supplierPicker.DataSource = purchasingDataSet;     // has Suppliers, Products, Orders tables
supplierPicker.DisplayMember = "CompanyName";
supplierPicker.ValueMember = "SupplierId";

DataSource

public new object DataSource

Gets or sets the data the control lists: a DataTable, DataView, DataSet, a BindingSource, or any list of objects.

Value
An object implementing IList or IListSource, or null (the default).
Remarks

In single-column mode this is the standard DataSource.

In multi-column mode the drop-down lists a table: a DataTable is used as it is; a DataView is copied, in its sort order and with its filter applied; a DataSet supplies the table named by DataMember, or its first table; and a list of objects is copied into a table with a column for each public property. The copy is refreshed when the source reports that its list has changed.

Set ColumnDataTypeFormatInfoContainers, DataSourceViewCustomSortingExpression and KeepBindingContextInSyncWithParent before the data source, since they act as it is bound.

See also

DataSourceViewCustomSortingExpression

public string DataSourceViewCustomSortingExpression

Gets or sets a sort expression that orders the rows of the multi-column drop-down, such as "City ASC, Name ASC".

Value
A sort expression in the syntax of DataView.Sort, or null (the default) for none.
Designer category
Multi-Column data display view
Remarks

The rows are put in this order when the control copies them from a list of objects or from a DataSet table, so set it before DataSource. Filtered results are ordered by it too, and while it is set the list does not sort itself by a column on opening.

A DataTable bound directly is shown in its own row order; to order one, bind a DataView of it with its DataView.Sort set instead.

DesiredFilterColumn

public int DesiredFilterColumn

Gets or sets the column the built-in filter of the multi-column drop-down starts on.

Value
The zero-based position of the column in the list. The default is 0, the first column.
Remarks

It selects the starting entry of the pane's "Filter on this column" list; the user can choose another. A position outside the list of columns is ignored.

See also

DisplayMember

public new string DisplayMember

Gets or sets the column or property of the data source whose value the control shows as the item's text.

Value
The column or property name. The default is an empty string, which shows each item's own text.
Remarks

In multi-column mode at run time a path such as "Customers.Name" is cut to the column name, "Name". It is also the column the control's auto-completion matches against. Setting it does not raise ComboBox.SelectedIndexChanged.

DisplayStyleIsFlat

public new bool DisplayStyleIsFlat

Gets or sets whether the control is drawn with its own flat look – the border, button and colours of BinaryComboBox – rather than as a standard Windows combo box.

Value
true for the flat look. The starting value follows whether Windows visual styles are on, which is true on current versions of Windows.
Default
true
Remarks

While DrawTheControlBasedOnWindowsOS is true (the default) the value follows the visual styles and a value assigned here is ignored; set that property to false first. Turning the flat look off re-creates the control's window.

DrawTheControlBasedOnWindowsOS

public bool DrawTheControlBasedOnWindowsOS

Gets or sets whether the control decides for itself between its flat look and the standard Windows look, by whether Windows visual styles are on.

Value
true to follow the visual styles. The default is true.
Remarks

With it on, DisplayStyleIsFlat follows the visual styles – flat while they are on, as they are on current versions of Windows – and a value assigned to it is ignored. To choose the look yourself, set this property to false first, then set DisplayStyleIsFlat.

Changing this property does not change the look by itself.

Example
// Always the standard Windows combo box look.
regionPicker.DrawTheControlBasedOnWindowsOS = false;
regionPicker.DisplayStyleIsFlat = false;

DropDownWindowBackgroundColor

public new Color DropDownWindowBackgroundColor

Gets or sets the background colour of the drop-down list, in both single-column and multi-column mode.

Value
The background colour. The default is SystemColors.Window.
Remarks

Setting it also sets MultiColumnDropListBackColor; setting that afterwards changes only the multi-column list.

DropDownWindowDisplayOrientation

public DropDownWindowDisplayOrientation DropDownWindowDisplayOrientation

Gets or sets which way the multi-column drop-down extends from the control: to the right of its left edge, or to the left of its right edge.

Value
DropDownWindowDisplayOrientation.Left, DropDownWindowDisplayOrientation.Right or DropDownWindowDisplayOrientation.Default. The default is DropDownWindowDisplayOrientation.Default.
Remarks

DropDownWindowDisplayOrientation.Left lines the window's right edge up with the control's and lets it grow leftwards – useful for a combo box near the right of a form, whose drop-down is wider than it is. DropDownWindowDisplayOrientation.Right and DropDownWindowDisplayOrientation.Default line the left edges up and grow rightwards.

DropStyleIsMultiColumn

public bool DropStyleIsMultiColumn

Gets or sets whether the drop-down button opens a multi-column window listing every column of the data source, instead of the ordinary single-column list.

Value
true for the multi-column drop-down. The default is false.
Designer category
Multi-Column data display view
Remarks

Bind DataSource – a DataTable, DataView, DataSet with DataMember, or a list of objects – and set DisplayMember to the column whose value the text area shows, and ValueMember to the column SelectedValue returns.

When the user picks a row, the control sets SelectedValue, SelectedIndexFromDropList and the text, and raises ComboBox.SelectedIndexChanged if the row is a different one. Read SelectedIndexFromDropList rather than ComboBox.SelectedIndex for the row's position in the data source.

The window lists the columns in ColumnsToDisplay, or all of them; see MultiColumnDropDownSize for its size and placement and the MultiColumnDropList properties for its look. Set MultiColumnDropDownSize only after turning this on.

Example
productPicker.DropStyleIsMultiColumn = true;
productPicker.DataSource = productsTable;          // Sku, Description, UnitPrice, InStock
productPicker.DisplayMember = "Description";
productPicker.ValueMember = "Sku";
productPicker.ColumnsToDisplay = new[] { "Sku", "Description", "UnitPrice" };
See also

DroppedDown

public new bool DroppedDown

Gets or sets whether the drop-down is open; setting it to true opens the multi-column drop-down, or the ordinary list.

Value
The value last assigned. The default is false.
Remarks

Reading the property returns what was last assigned to it, not whether a list is open now: the user opening or closing the list does not change it. Assigning false does not close an open list; to close the multi-column drop-down from code call CloseMultiColumnDropDownListWindow.

EnableAlphaBlendingForFilterAndGroupingPanelBackColor

public bool EnableAlphaBlendingForFilterAndGroupingPanelBackColor

Gets or sets whether the filter and grouping pane's colour is blended with the window colour into a paler tint.

Value
true to blend. The default is true.
Designer category
Multi-Column data display view
Remarks

The amount is AlphaBlendingfactorForFilterAndGroupingPanelBackColor. With it off, FilterAndGroupingPanelBackColor is used as it is, and an empty colour leaves the pane in its default colour.

EnableColumnSorting

public bool EnableColumnSorting

Gets or sets whether the user can sort the multi-column drop-down by clicking a column heading.

Value
true to allow sorting. The default is true.
Default
true
Remarks

A first click sorts ascending and the next descending, and the heading shows an arrow in MultiColumnViewSortingGlyphColor. With sorting on, the list also sorts itself when it opens; see MultiColumnModeSourceDataSortedColumnIndex.

With it off the headings cannot be clicked.

See also

EnableDrawingHeaderFooterWhenInMultiColumnMode

public bool EnableDrawingHeaderFooterWhenInMultiColumnMode

Gets or sets whether the multi-column drop-down is framed by a header band and a footer band, set up in MultiColumnDropDownWindowConfigurationData.

Value
true to draw the header and footer. The default is false.
Designer category
Multi-Column data display view
Remarks

The header carries MultiColumnDropDownWindowConfiguration.HeaderText and an icon or bitmap, the footer MultiColumnDropDownWindowConfiguration.FooterText, both on a gradient from MultiColumnDropDownWindowConfiguration.HeaderControlRenderingStartColor to MultiColumnDropDownWindowConfiguration.HeaderControlRenderingEndColor, inside a frame BinaryComboBox.MultiColumnDropDownWindowBorderThickness wide.

The column headings take the same gradient; without the header and footer they run from CustomPaintingColor to the window colour.

Example
var window = supplierPicker.MultiColumnDropDownWindowConfigurationData;
window.HeaderText = "Approved suppliers";
window.FooterText = "Double-click a supplier to choose it";
window.HeaderImageType = HeaderImageStyle.None;
window.HeaderControlRenderingStartColor = Color.SteelBlue;
window.HeaderAndFooterTextForeColor = Color.White;
supplierPicker.EnableDrawingHeaderFooterWhenInMultiColumnMode = true;

EnableUserColumnResizing

public bool EnableUserColumnResizing

Gets or sets whether the user can drag the edges of the multi-column drop-down's column headings to resize the columns.

Value
true to allow resizing. The default is true.
Default
true
See also

EnforceItemsInList

public bool EnforceItemsInList

Gets or sets whether the control checks the text the user types against its list, raising NotInList when it matches no item.

Value
true to check the text. The default is false.
Default
false
Remarks

The check runs when the user leaves the control, and also as they type if RaiseNotInListWhenTyping is on. The control raises the event but does not change or reject the text; the handler does that.

FilterAndGroupingPanelBackColor

public Color FilterAndGroupingPanelBackColor

Gets or sets the background colour of the multi-column drop-down's filter and grouping pane.

Value
The pane's colour, or Color.Empty (the default) to use the accent colour – the header's start colour when the header and footer are drawn, otherwise CustomPaintingColor.
Designer category
Multi-Column data display view
Remarks

While EnableAlphaBlendingForFilterAndGroupingPanelBackColor is on (the default) the colour is blended with the window colour by AlphaBlendingfactorForFilterAndGroupingPanelBackColor, giving a pale tint; with it off the colour is used as it is.

FilteringIsON

public bool FilteringIsON

Gets or sets whether filtering is switched on in the multi-column drop-down's options pane when the drop-down opens.

Value
true to open with the "Use filter to retrieve data" box ticked. The default is false.
Remarks

The pane exists only while ShowFilterOptionsInMultiColumnMode is true. Turning filtering on does not filter anything until the user types a filter; the column it applies to starts as DesiredFilterColumn.

See also

GroupItemsWhenInMultiColumnDisplayMode

public bool GroupItemsWhenInMultiColumnDisplayMode

Gets or sets whether the multi-column drop-down opens with its rows grouped under headings, one for each different value in a column.

Value
true to open grouped. The default is false, a plain table.
Designer category
Multi-Column data display view
Remarks

The rows are grouped by the column at GroupMultiColumnDisplayModeDataBasedOnThisColumn, by the exact text each row shows in it. The group headings are ordered by MultiColumnDefaultGroupedModeGroupSortingOrder.

The user can turn grouping on and off from the drop-down's shortcut menu, and, with ShowFilterOptionsInMultiColumnMode on, choose the column in the options pane.

Example
// Customers grouped by city.
accountPicker.ColumnsToDisplay = new[] { "City", "Name", "AccountNo" };
accountPicker.GroupMultiColumnDisplayModeDataBasedOnThisColumn = 0;
accountPicker.GroupItemsWhenInMultiColumnDisplayMode = true;
accountPicker.MultiColumnDefaultGroupedModeGroupSortingOrder = SortOrder.Ascending;

GroupMultiColumnDisplayModeDataBasedOnThisColumn

public int GroupMultiColumnDisplayModeDataBasedOnThisColumn

Gets or sets the column the multi-column drop-down groups its rows by.

Value
The zero-based position of the column in the list. The default is 0, the first column.
Designer category
Multi-Column data display view
Remarks

Used when the list opens grouped; see GroupItemsWhenInMultiColumnDisplayMode.

HeadersToDisplay

public string[] HeadersToDisplay

Gets or sets the heading text of each column of the multi-column drop-down, in place of the column names.

Value
One heading per column shown, in the same order; or null (the default) to head each column with its name.
Designer category
Multi-Column data display view
Exceptions
System.IndexOutOfRangeException
In multi-column mode, the number of headings does not match the number of columns.
Remarks

An empty array, or one whose first heading is blank, means null.

In multi-column mode the number of headings is checked: it must equal the number of names in ColumnsToDisplay, or, without those, the number of columns in the data source. Otherwise an IndexOutOfRangeException is thrown – so set ColumnsToDisplay first.

See also

IsAutoCompleteModeAppendSuggestInMultiColumnMode

public bool IsAutoCompleteModeAppendSuggestInMultiColumnMode

Gets or sets whether the multi-column suggestion list also fills in the rest of the first matching item's text, the way SuggestAppend does.

Value
true to fill in the text as well. The default is false.
Remarks

The filled-in part is selected, so the next key replaces it. Applies only with AutoCompleteStyleForMultiColumnModeIsMultiColumn on.

IsCustomisationOfColumnDisplayEnabledInMultiColumnAutoSuggestMode

public bool IsCustomisationOfColumnDisplayEnabledInMultiColumnAutoSuggestMode

Gets or sets whether the multi-column suggestion list shows only the columns in ColumnsToDisplay, rather than every column of the data source.

Value
true to show only those columns. The default is false.
Remarks

The columns are headed by HeadersToDisplay when it has one heading for each of them, and otherwise by their names. Without ColumnsToDisplay every column is shown.

IsFilterSearchResultBasedOnColumnDataType

public bool IsFilterSearchResultBasedOnColumnDataType

Gets or sets whether the formats in ColumnDataTypeFormatInfoContainers also set the type each column is filtered as, so the built-in filter compares numbers and dates by value.

Value
true to type the columns by their format. The default is true.
Remarks

Applies when the control copies the data source into a table of its own – a list of objects or a DataSet – and ColumnDataTypeFormatInfoContainers is set. A column formatted as a decimal becomes a decimal column, currency and thousands-separated whole numbers become floating-point columns, and dates become date columns; the built-in filter then matches them as BuiltinFilterOnNonStringTypeColumnFilterMode says, rather than as text.

With it off, each column keeps the type of its property.

IsSourceDataPreSorted

public bool IsSourceDataPreSorted

Gets or sets whether the data source is already in the order the multi-column drop-down should show, so the list does not sort it again.

Value
true to keep the source's order. The default is false, which sorts the list by a column when it opens.
Remarks

With it on, the list opens in the source's order when MultiColumnModeSourceDataSortedColumnIndex is 0, instead of sorting itself by that column. The user can still sort by clicking a heading.

See also

ItemSelectionClick

public ItemSelectionClick ItemSelectionClick

Gets or sets whether the user picks a row of the multi-column drop-down with a single click or a double-click.

Value
ItemSelectionClick.DoubleClick (the default) or ItemSelectionClick.SingleClick.
Default
ItemSelectionClick.DoubleClick
Designer category
Multi-Column data display view
Remarks

Enter always picks the highlighted row. A double-click leaves single clicks free for moving the highlight and for the headings; a single click suits short lists where the user picks at once.

KeepBindingContextInSyncWithParent

public bool KeepBindingContextInSyncWithParent

Gets or sets whether the multi-column combo box moves the current record of the form's data binding when the user picks a row, and follows it when the form moves it.

Value
true to keep the two in step. The default is false.
Designer category
Multi-Column data display view
Remarks

When the user picks a row, the control moves the current record of its parent's binding for the same data source, so text boxes on the form bound to that source show the record picked; and when the current record is moved elsewhere (by a navigator, for example), the selection here follows.

Applies only while DropStyleIsMultiColumn is true. Set it before DataSource.

KeepTheFilterAndGroupingViewsCollapsedAtStartUp

public bool KeepTheFilterAndGroupingViewsCollapsedAtStartUp

Gets or sets whether the filter and grouping sections of the multi-column drop-down's options pane open folded to their title lines.

Value
true to open them folded. The default is true.
Remarks

The user unfolds each section with its + button. To hide the whole pane instead, set KeepTheFilterAndGroupingViewsPaneFullyCollapsedAtStartup.

KeepTheFilterAndGroupingViewsPaneFullyCollapsedAtStartup

public bool KeepTheFilterAndGroupingViewsPaneFullyCollapsedAtStartup

Gets or sets whether the multi-column drop-down opens with its filter and grouping pane hidden, leaving only the button that shows it.

Value
true to open with the pane hidden. The default is false.
Remarks

The user shows the pane with the button at the bottom of the window, captioned by MultiColumnViewUIElementsTextProvider.WindowItemShowFilterAndGroupingOptions. Applies only while ShowFilterOptionsInMultiColumnMode is true.

MultiColumnDefaultGroupedModeGroupSortingOrder

public SortOrder MultiColumnDefaultGroupedModeGroupSortingOrder

Gets or sets the order of the group headings when the multi-column drop-down opens with its rows grouped.

Value
Ascending or Descending to sort the headings by their text; None, the default, to keep them in the order their values first appear.
Remarks

The value also seeds the direction of the sort the list applies when it opens (see MultiColumnModeSourceDataSortedColumnIndex): opening reverses it once, so with Ascending rows sorted on the first column open in descending order, and with None or Descending in ascending order.

See also

MultiColumnDropDownSize

public Size MultiColumnDropDownSize

Gets or sets the size of the multi-column drop-down window, in logical pixels.

Value
The window's width and height in logical pixels (1/96 inch), or Size.Empty (the default) to size the window to its content.
Designer category
Multi-Column data display view
Remarks

Size.Empty sizes the window to show every column in full and about a dozen rows, and never narrower than the combo box. Any other value is the size to open at, scaled to the display the combo box is on – a value in a form's designer file keeps meaning what it meant at 100%. Either way the window is kept within the working area of that display.

When the user resizes the window, the size they chose is stored here, in logical pixels, and the next open uses it. Setting the property is ignored unless DropStyleIsMultiColumn is true, so set that first.

MultiColumnDropDownWindowConfigurationData

public MultiColumnDropDownWindowConfiguration MultiColumnDropDownWindowConfigurationData

Gets or sets the settings for the multi-column drop-down's header and footer bands, its column headings, and its no-data message.

Value
The settings. The default is an instance with its own defaults; change its properties rather than replacing it.
Designer category
Multi-Column data display view
Remarks

The header and footer are drawn only while EnableDrawingHeaderFooterWhenInMultiColumnMode is true; the column heading font and colour and the no-data message apply always. In the designer the settings expand in the Properties window and are saved with the form.

See also

MultiColumnDropListBackColor

public Color MultiColumnDropListBackColor

Gets or sets the background colour of the rows in the multi-column drop-down.

Value
The background colour. The default is SystemColors.Window.
Designer category
Multi-Column data display view
See also

MultiColumnDropListFont

public Font MultiColumnDropListFont

Gets or sets the font of the rows in the multi-column drop-down.

Value
The font. The default is Control.DefaultFont.
Designer category
Multi-Column data display view
Remarks

The row height, and the height of a window that sizes itself, follow this font. The headings use MultiColumnDropDownWindowConfiguration.ColumnHeaderFont.

MultiColumnDropListForeColor

public Color MultiColumnDropListForeColor

Gets or sets the colour of the text in the rows of the multi-column drop-down.

Value
The text colour. The default is SystemColors.WindowText.
Designer category
Multi-Column data display view

MultiColumnDropListGridLines

public bool MultiColumnDropListGridLines

Gets or sets whether lines are drawn between the rows and columns of the multi-column drop-down.

Value
true to draw grid lines. The default is true.
Designer category
Multi-Column data display view

MultiColumnDropListHoverSelection

public bool MultiColumnDropListHoverSelection

Gets or sets whether a row of the multi-column drop-down is highlighted when the pointer rests on it, without a click.

Value
true to highlight on hover. The default is false.
Designer category
Multi-Column data display view
Remarks

Highlighting a row does not pick it; the user still picks with the click set by ItemSelectionClick, or Enter.

MultiColumnDropListWindowIsResizable

public bool MultiColumnDropListWindowIsResizable

Gets or sets whether the user can resize the multi-column drop-down by dragging its edges.

Value
true for a resizable window. The default is true.
Remarks

A resizable window has a sizing border and a size grip; a size the user drags it to is kept in MultiColumnDropDownSize for the next time it opens. With it off the window has a fixed, single-line border.

MultiColumnDroplistWindowAnimationStyle

public MultiColumnDroplistWindowAnimationStyle MultiColumnDroplistWindowAnimationStyle

Gets or sets how the multi-column drop-down animates as it closes after the user picks a row.

Value
MultiColumnDroplistWindowAnimationStyle.Vanish, MultiColumnDroplistWindowAnimationStyle.ReSize or MultiColumnDroplistWindowAnimationStyle.None. The default is MultiColumnDroplistWindowAnimationStyle.None.
Designer category
Multi-Column data display view
Remarks

The animation runs only while AnimateDropDownWindow is true and AnimationInterval is above 0, and only when the window closes because a row was picked – not on Escape or a click elsewhere.

MultiColumnModeSourceDataSortedColumnIndex

public int MultiColumnModeSourceDataSortedColumnIndex

Gets or sets the column the multi-column drop-down is sorted by when it opens.

Value
The zero-based position of the column in the list. The default is 0, the first column.
Remarks

On opening, the list sorts itself as if the user had clicked this column's heading, and the heading shows the sort arrow. With IsSourceDataPreSorted on, name the column the data is already sorted by: 0 leaves the rows in the source's order, and any other column is sorted again so its heading shows the arrow.

Nothing is sorted on opening when DataSourceViewCustomSortingExpression is set, or when EnableColumnSorting is off. The opening sort raises CustomSorting like a click does.

MultiColumnViewBusyProcessingText

public string MultiColumnViewBusyProcessingText

Gets or sets the message the multi-column drop-down shows while it rebuilds its rows – when the user filters or groups them.

Value
The message. The default is "Processing the query... please wait...".
See also

MultiColumnViewNoDataFoundText

public string MultiColumnViewNoDataFoundText

Gets or sets the message the multi-column drop-down shows when a filter leaves no rows.

Value
The message. The default is "There is no data to display.".
Remarks

A data source with no rows at all shows MultiColumnDropDownWindowConfiguration.NoDataToDisplayMessageText instead.

MultiColumnViewSortingGlyphColor

public Color MultiColumnViewSortingGlyphColor

Gets or sets the colour of the arrow drawn in the heading of the column the multi-column drop-down is sorted by.

Value
The arrow colour. The default is SystemColors.WindowText.
Remarks

The arrow points up for an ascending sort and down for a descending one. It is drawn only when the column is wide enough to hold it beside the heading text.

MultiColumnViewUIElementsTextProvider

public MultiColumnViewUIElementsTextProvider MultiColumnViewUIElementsTextProvider

Gets or sets the captions, messages and menu text the multi-column drop-down shows, so they can be translated.

Value
The text provider. The default has the English text; it is never null unless you set it so.
Designer category
Multi-column UI elements text customization
Remarks

Change the provider's properties, in the designer or in code, before the drop-down opens; the window reads them each time it opens. The busy and no-data messages are MultiColumnViewBusyProcessingText and MultiColumnViewNoDataFoundText.

Example
var text = productPicker.MultiColumnViewUIElementsTextProvider;
text.ContextMenuItemEnableDataGroupingText = "Grouper les données";
text.ContextMenuItemExportDataToCSV = "Exporter au format CSV";
text.WindowItemUseFilterToRetrieveData = "Filtrer les données";

RaiseNotInListWhenTyping

public bool RaiseNotInListWhenTyping

Gets or sets whether NotInList is raised as the user types, rather than only when they leave the control.

Value
true to check as the user types. The default is false.
Default
false
Remarks

Applies only while EnforceItemsInList is true. As the user types, the event is raised whenever no item starts with the text so far – so it warns as soon as the text cannot lead to an item. It can be raised more than once for one key; keep the handler light (a label or an error provider rather than a message box).

The check on leaving the control, for an exact match, still runs.

SelectedIndexFromDropList

public int SelectedIndexFromDropList

Gets or sets the position, in the data source, of the row picked in the multi-column drop-down.

Value
The zero-based row index, or -1 when no row is picked. The default is -1.
Designer category
Multi-Column data display view
Remarks

Read it in a ComboBox.SelectedIndexChanged handler to find the record the user picked, for example to pass to GetTheColumnValue. In multi-column mode prefer it to ComboBox.SelectedIndex.

In multi-column mode, setting it selects that row and shows its DisplayMember value; -1, or a row that does not exist, clears the text and the selection. Outside multi-column mode setting it only stores the number.

SelectedValue

public new object SelectedValue

Gets or sets the ValueMember value of the selected item – typically the key of the record the user picked.

Value
The selected item's value, or null when nothing is selected.
Remarks

In single-column mode this is the standard SelectedValue.

In multi-column mode, setting it selects the first row whose ValueMember value has the same text as the value given, and shows that row's DisplayMember value; a value no row has leaves the selection as it was. Setting null or Value clears the text. It is ignored while ValueMember is empty. For a data source that is a list of objects but not an IBindingList – a List or an array – only the first item's value is found; any other value selects the first row and clears the text, so bind such data through a BindingList.

The property can be data-bound, which makes the combo box a lookup: bind it to the foreign key of the record being edited.

Example
// Show the customer of the order being edited, and write the user's choice back to it.
accountPicker.DataBindings.Add("SelectedValue", orderBindingSource, "AccountNo",
    true, DataSourceUpdateMode.OnPropertyChanged);

ShareCustomMultiColumnSizeAcrossDataListAndFilterGroupingOptionsPane

public bool ShareCustomMultiColumnSizeAcrossDataListAndFilterGroupingOptionsPane

Gets or sets whether the multi-column drop-down keeps its size when the user shows or hides the filter and grouping pane, the pane taking its room from the list.

Value
true to keep the window's size. The default is true.
Remarks

With it off, showing or hiding the pane makes the window taller where the list would otherwise be left with too little room. The pane is shown by ShowFilterOptionsInMultiColumnMode.

ShouldAllowDragDropOfColumns

public bool ShouldAllowDragDropOfColumns

Gets or sets whether the user can drag the multi-column drop-down's column headings to change the order of the columns.

Value
true to allow reordering. The default is false.
Default
false
Remarks

Without reordering, the list stretches its last column to fill the window's width, so no empty heading is left at the right. With reordering allowed it does not, and an empty heading area may show beside the last column.

ShouldAllowUserInputWhileProcessingMultiColumnAutoCompleDropDownView

public bool ShouldAllowUserInputWhileProcessingMultiColumnAutoCompleDropDownView

Gets or sets whether the user can go on typing while the multi-column suggestion list is open.

Value
true to keep the keyboard in the text area. The default is true.
Remarks

With it on, the list stays open as the user types and closes when they click anywhere outside it and the control. With it off, the list takes the keyboard when it opens, so the user can move through it with the arrow keys, and it closes by itself when it loses the focus. See AutoCompleteStyleForMultiColumnModeIsMultiColumn.

ShouldPersistUserSetColumnWidthsAcrossFilterSessions

public bool ShouldPersistUserSetColumnWidthsAcrossFilterSessions

Gets or sets whether the column widths the user has set in the multi-column drop-down are kept when a filter is applied or cleared.

Value
true to keep the user's widths. The default is false, which sizes the columns again for each filtered view.

ShowDropDownMultiColumnWindowAfterAdjustingForVirtualAvaliableScreenSpace

public bool ShowDropDownMultiColumnWindowAfterAdjustingForVirtualAvaliableScreenSpace

Gets or sets whether the multi-column drop-down is moved and, if need be, shortened so that it fits on the screen.

Value
true to keep the window on the screen. The default is true.
Remarks

With it on, the window opens below the control if it fits there, above it if it fits there instead, and otherwise on the side with more room, cut to fit; it is moved sideways as far as it must be to stay within the working area of the control's display. With it off, it always opens just below the control, where it may run off the screen.

CustomDropDownWindowLocationPoint, when set, takes precedence over both.

See also

ShowEmptyDropListViewWhenThereAreNoData

public bool ShowEmptyDropListViewWhenThereAreNoData

Gets or sets whether the drop-down opens when there is nothing to list.

Value
true to open it anyway. The default is true.
Remarks

With it on, an empty multi-column drop-down opens as a small window showing MultiColumnDropDownWindowConfiguration.NoDataToDisplayMessageText, and an empty ordinary list opens empty. With it off, clicking the button of an empty control does nothing.

ShowFilterOptionsInMultiColumnMode

public bool ShowFilterOptionsInMultiColumnMode

Gets or sets whether the multi-column drop-down has a filter and grouping pane at its foot, for the user to filter and group the rows.

Value
true to include the pane. The default is true.
Designer category
Multi-Column data display view
Remarks

The pane offers a built-in filter on a chosen column – text columns keep the rows that start with what the user types, other columns follow BuiltinFilterOnNonStringTypeColumnFilterMode – and a custom filter expression in the syntax of Expression, such as Balance > 1000 AND City = 'Leeds'. The built-in filter can apply as the user types, or when they press OK. The pane also turns grouping on and picks the column to group by.

A status strip under the pane has a button that hides and shows it, and the shortcut menu gains commands to switch filtering and the status strip on and off. The pane is not shown when the data source has no rows.

The pane's starting state is set by FilteringIsON, DesiredFilterColumn, KeepTheFilterAndGroupingViewsCollapsedAtStartUp and KeepTheFilterAndGroupingViewsPaneFullyCollapsedAtStartup; its captions by MultiColumnViewUIElementsTextProvider.

SizeForMultiColumnAutoCompleteSuggestionDropDownWindow

public Size SizeForMultiColumnAutoCompleteSuggestionDropDownWindow

Gets or sets the size of the multi-column suggestion list.

Value
The size in logical pixels, scaled to the display; or Size.Empty (the default) for MultiColumnDropDownSize less 75 pixels in height – or 500 by 175 while that is empty.
Remarks

SizesForMultiColumnAutoCompleteSuggestionDropDownWindowColumns

public int[] SizesForMultiColumnAutoCompleteSuggestionDropDownWindowColumns

Gets or sets the width of each column of the multi-column suggestion list.

Value
Widths in pixels, in column order; or null (the default) to size each column to its heading.
Remarks

The widths are applied as given, without scaling to the display. A width beyond the last column adds an empty column. See AutoCompleteStyleForMultiColumnModeIsMultiColumn.

TableToLoad

public DataTable TableToLoad

Gets or sets the table the multi-column drop-down lists. Kept for older applications; set DataSource instead.

Value
The table, or null. The default is null.
Designer category
Multi-Column data display view
Remarks

Setting a table sets DataSource to it. Setting null leaves the data source as it is.

Reading it returns the table the multi-column drop-down lists: the bound DataTable itself, or the table the control builds from any other kind of data source.

ValueMember

public new string ValueMember

Gets or sets the column or property of the data source whose value SelectedValue returns, such as the record's key.

Value
The column or property name. The default is an empty string.
Remarks

In multi-column mode at run time a path such as "Customers.AccountNo" is cut to the column name, "AccountNo", so the same setting works for a DataSet and for its table. Setting it does not raise ComboBox.SelectedIndexChanged.

Methods

CloseMultiColumnDropDownListWindow

public void CloseMultiColumnDropDownListWindow()

Closes the multi-column drop-down if it is open, without picking a row.

Remarks

Does nothing when the drop-down is not open. The selection and text stay as they were.

Dispose

protected override void Dispose(bool disposing)

Removes the control's application message filter and releases its resources.

Parameters
disposing
true when called from Dispose().

GetRowDataString

protected string GetRowDataString(int index)

Returns the text shown for one row of the data source: its DisplayMember value.

Parameters
index
The zero-based row in DataSource.
Returns

The row's display text; the object's own ToString text when DisplayMember is empty; or an empty string when there is no data source, the row does not exist or the value cannot be read.

GetTheColumnValue

public string GetTheColumnValue(int desiredRowIndex, string desiredColumnName)

Returns the value of one column of one row of the data source, as text – for reading another column of the record the user picked.

Parameters
desiredRowIndex
The zero-based row in DataSource, usually SelectedIndexFromDropList.
desiredColumnName
The name of the column, or of the property for a list of objects.
Returns

The value as text; or an empty string when the control is not in multi-column mode, the row is negative or does not exist, the name is empty or unknown, or (for a list of objects) the property is not a string.

Example
accountPicker.SelectedIndexChanged += (sender, e) =>
{
    int row = accountPicker.SelectedIndexFromDropList;
    cityLabel.Text = accountPicker.GetTheColumnValue(row, "City");
};

MakeBlank

public new void MakeBlank()

Clears the selection, so the control shows no item, without raising ComboBox.SelectedIndexChanged.

Remarks

ComboBox.SelectedIndex becomes -1 and the text area is emptied. Because the change is not reported, SelectedIndexFromDropList keeps its previous value.

OnDropDown

protected override void OnDropDown(System.EventArgs e)

Opens the drop-down: in multi-column mode it builds and shows the multi-column window; otherwise it raises the ComboBox.DropDown event as usual.

Parameters
e
The event data.
Remarks

In multi-column mode the ComboBox.DropDown event is not raised; use DropDownAboutToBeShown. While the window is being built the text area shows BusyIndicatorText.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

Raises the Control.KeyDown event after opening the multi-column drop-down for Alt+Down, Alt+Up or F4, when the control is in multi-column mode.

Parameters
e
The key pressed.
Remarks

DropDownAboutToBeShown is raised first, and can keep the drop-down closed.

OnKeyUp

protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)

Raises the Control.KeyUp event and then does the control's typing work: completing the text, checking it for NotInList, and showing the multi-column suggestion list.

Parameters
e
The key released.

OnLeave

protected override void OnLeave(EventArgs e)

Raises the Control.Leave event, then raises NotInList if EnforceItemsInList is on and the text equals no item, and closes the multi-column suggestion list.

Parameters
e
The event data.

OnSelectedIndexChanged

protected override void OnSelectedIndexChanged(EventArgs e)

Raises the ComboBox.SelectedIndexChanged event after the control's own bookkeeping.

Parameters
e
The event data.
Remarks

Before the event is raised the control puts back the previous item when it is in extended read-only mode, records the new SelectedIndexFromDropList, and moves the form's current record when KeepBindingContextInSyncWithParent is set. Changes the control makes while it is loading or rebinding its data are not reported.

OnTextChanged

protected override void OnTextChanged(EventArgs te)

Raises the Control.TextChanged event, then raises NotInList if the new text cannot lead to an item and RaiseNotInListWhenTyping is on.

Parameters
te
The event data.

PaintControlWithData

protected override void PaintControlWithData(Graphics g, Rectangle bounds, int Index, bool ifSelected, bool toEdit)

Draws one item's text, in the list or on the closed control, over the background the base draws.

Parameters
g
The surface to draw on.
bounds
The item's bounds, in device pixels.
Index
The index of the item, or -1 for none.
ifSelected
true when the item is the highlighted one.
toEdit
true when drawing the closed control.
Remarks

Items from a data source are aligned by BinaryComboBox.DropDownItemTextAlignment and show their DisplayMember value.

PreFilterMessage

public bool PreFilterMessage(ref Message m)

Watches the application's mouse clicks so that, while the multi-column suggestion list lets the user go on typing, a click outside the list and the control closes it.

Parameters
m
The message about to be dispatched.
Returns

Always false: every message carries on to its target.

Remarks

Part of the IMessageFilter the control registers when it is created and removes when it is disposed. There is no need to call it.

RefreshPaint

protected override void RefreshPaint(Graphics g, Rectangle bounds, int Index, bool ifSelected, bool toEdit)

Redraws the selected item's text on the closed control, aligned by BinaryComboBox.TextAlignment.

Parameters
g
The surface to draw on.
bounds
The control's face, in device pixels.
Index
The index of the selected item, or -1 for none.
ifSelected
true to draw the item highlighted.
toEdit
true when drawing the closed control.

SetData

protected override void SetData()

Draws the disabled control, with the selected item's text in SystemColors.ControlDark.

WndProc

protected override void WndProc(ref System.Windows.Forms.Message m)

Processes Windows messages, raising DropDownAboutToBeShown when the user clicks the control or presses Alt+Down, and opening the multi-column drop-down in place of the ordinary list.

Parameters
m
The message to process.

Events

AutoCompleting

public event AutoCompletingHandler AutoCompleting

Occurs after each key the user types, just before the control completes the text, and lets the handler skip the completion.

Remarks

Raised only when the control's own completion would run: AutoComplete on and AutoCompleteMode None. Skipping it leaves the typed text as it is, for that key only.

Example
// Let the user type a new product code freely once it starts with "NEW-".
productPicker.AutoCompleting += (object sender, ref bool cancel) =>
{
    cancel = productPicker.Text.StartsWith("NEW-", StringComparison.OrdinalIgnoreCase);
};

CustomSorting

public event CustomSortingHandler CustomSorting

Occurs when the multi-column drop-down is about to sort its rows by a column, so the application can supply its own comparison or cancel the sort.

Remarks

Raised when the user clicks a column heading, and once as the drop-down opens for its first sort (see MultiColumnModeSourceDataSortedColumnIndex). Raised only while EnableColumnSorting is true.

After the handler returns, the list is sorted with CustomComparerImplementor – so set it in the handler for the columns that need it, and back to null for the built-in comparison, which orders values that read as numbers by their value and everything else as text, ignoring case.

Example
// In the form: dates in the "Ordered" column read "12 Mar 2024", which does not sort as text.
private bool orderedNewestFirst;

private void HookUpOrderSorting()
{
    orderPicker.CustomSorting += (object sender, ref bool cancel, int column, string heading) =>
    {
        if (heading == "Ordered")
        {
            orderedNewestFirst = !orderedNewestFirst;
            orderPicker.CustomComparerImplementor = new DateColumnComparer(column, orderedNewestFirst);
        }
        else
        {
            orderPicker.CustomComparerImplementor = null;   // the built-in comparison
        }
    };
}

public sealed class DateColumnComparer : IComparer
{
    private readonly int column;
    private readonly bool descending;

    public DateColumnComparer(int column, bool descending)
    {
        this.column = column;
        this.descending = descending;
    }

    public int Compare(object x, object y)
    {
        DateTime a = DateTime.Parse(((ListViewItem)x).SubItems[column].Text);
        DateTime b = DateTime.Parse(((ListViewItem)y).SubItems[column].Text);
        return descending ? b.CompareTo(a) : a.CompareTo(b);
    }
}

DropDownAboutToBeShown

public event DropDownProcessHandler DropDownAboutToBeShown

Occurs when the user is about to open the drop-down – by clicking the control, or pressing Alt+Down, Alt+Up or, in multi-column mode, F4 – and lets the handler stop it.

Remarks

Set the handler's cancelNow argument to true to keep the drop-down closed, for example until another field has been filled in. Opening it from code through DroppedDown does not raise the event.

The event can be raised more than once for one gesture (on the key going down and again on its release), so keep the handler quick and free of side effects such as message boxes.

Example
contactPicker.DropDownAboutToBeShown += (object sender, ref bool cancelNow) =>
{
    // There is nothing to choose from until a customer is chosen.
    cancelNow = customerPicker.SelectedIndex < 0;
};

NotInList

public event NotInListHandler NotInList

Occurs when the text the user typed matches no item in the list, so the application can reject it or add it.

Remarks

Raised only while EnforceItemsInList is true. By default it is raised when the user leaves the control and the text equals no item. With RaiseNotInListWhenTyping on it is also raised as the user types, whenever no item starts with the text so far. Empty text is never reported. Case is matched as AutoCompleteIsCaseSensitive says.

The control does not change the text itself; the handler decides what happens.

Example
cityPicker.EnforceItemsInList = true;
cityPicker.NotInList += (sender, userText) =>
{
    var answer = MessageBox.Show(this, "\"" + userText + "\" is not in the list. Add it?",
        "New city", MessageBoxButtons.YesNo);
    if (answer == DialogResult.Yes)
        cityPicker.Items.Add(userText);
    else
        cityPicker.MakeBlank();
};