HypernovaDesktop Components · docs
Binarymission
WinForms › Combo Box › BinaryComboBoxColumn

BinaryComboBoxColumn

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

A DataGridView column whose cells are edited with a BinaryTextComboBox – so a grid cell can offer the multi-column drop-down, its sorting, grouping and filtering, and the Hypernova look.

public class BinaryComboBoxColumn : DataGridViewComboBoxColumn

Inherits from / implements: DataGridViewComboBoxColumn

Remarks

What it is for

Use it for a lookup column in an editable grid: the product on an order line, the account on a journal entry. It is a DataGridViewComboBoxColumn, so DataGridViewComboBoxColumn.DataSource, DataGridViewComboBoxColumn.DisplayMember, DataGridViewComboBoxColumn.ValueMember and DataGridViewColumn.DataPropertyName work as they do there; the cells show the display value while they are not being edited.

How the settings reach the editor

The column's other properties mirror those of BinaryTextComboBox. Each time a cell starts editing, the grid's one editing combo box is given the column's settings, so they can be changed at any time and apply from the next edit. Two are named differently: DropDownWindowBorderColor becomes the editor's BinaryComboBox.CustomControlBorderColor and DropDownWindowPaintingColor its BinaryTextComboBox.CustomPaintingColor.

Several defaults differ from the combo box's: the filter and grouping pane is off, columns can be reordered, completion uses the framework's Append mode, ignoring case, and the drop-down opens 150 by 125 logical pixels.

Examples

var productColumn = new BinaryComboBoxColumn
{
    HeaderText = "Product",
    DataPropertyName = "ProductSku",
    DataSource = productsTable,              // Sku, Description, UnitPrice
    DisplayMember = "Description",
    ValueMember = "Sku",
    Width = 220,
    DropStyleIsMultiColumn = true,
    ColumnsToDisplay = new[] { "Sku", "Description", "UnitPrice" },
    HeadersToDisplay = new[] { "SKU", "Product", "Price" },
    MultiColumnDropDownSize = new Size(420, 240),
    DropDownWindowPaintingColor = Color.SteelBlue,
};
orderLinesGrid.Columns.Add(productColumn);

See also

Members at a glance

Constructors
BinaryComboBoxColumnInitialises a new column whose cells are BinaryTreeListViewComboBoxCell cells, edited with a BinaryTextComboBox.
Properties
AlphaBlendingfactorForFilterAndGroupingPanelBackColorGets or sets how strongly the pane colour shows when the filter and grouping pane's colour is blended.
AutoCompleteBasedOnCompleteMatchWithAnItemInTheListGets or sets which item the editor's own completion uses when several start with the typed text: the first, or the last.
AutoCompleteIsCaseSensitiveGets or sets whether the editor's own 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 for the editing combo box.
AutoCompleteSourceGets or sets where the framework's auto-completion takes its suggestions from.
CSVFileSaveAsGets or sets the file the editor's "Export data to CSV" command writes to.
ColumnWidthsGets or sets the width of each column of the editor's multi-column drop-down.
ColumnsToDisplayGets or sets which columns of DataGridViewComboBoxColumn.DataSource the editor's multi-column drop-down shows, and in what order.
ComboBoxControlFontGets or sets the font of the editing combo box's text area.
ComboBoxControlFontIsSameAsDropListWindowFontGets or sets whether the editing combo box uses the drop-down's row font (MultiColumnDropListFont) in place of ComboBoxControlFont.
CustomComparerImplementorGets or sets a comparison of your own for sorting the rows of the editor's multi-column drop-down.
CustomDropDownWindowLocationPointGets or sets a fixed screen position for the top-left corner of the editor's multi-column drop-down.
DropDownStyleGets or sets whether the user can type in the editing combo box, or only pick from its list.
DropDownWindowBorderColorGets or sets the colour of the editing combo box's border and of the outline round its drop-down button.
DropDownWindowDisplayOrientationGets or sets which way the editor's multi-column drop-down extends from the cell: to the right of its left edge, or to the left of its right edge.
DropDownWindowPaintingColorGets or sets the accent colour of the editing combo box – its drop-down button, highlighted item and the multi-column drop-down's accents.
DropStyleIsMultiColumnGets or sets whether the column's cells open a multi-column drop-down listing every column of DataGridViewComboBoxColumn.DataSource, instead of the ordinary list.
EnableAlphaBlendingForFilterAndGroupingPanelBackColorGets or sets whether the filter and grouping pane's colour is blended with the window colour into a paler tint.
EnableDrawingHeaderFooterWhenInMultiColumnModeGets or sets whether the editor's multi-column drop-down is framed by the header and footer bands set up in MultiColumnDropDownWindowConfiguration.
EnableUserColumnResizingGets or sets whether the user can drag the edges of the editor's drop-down headings to resize its columns.
FilterAndGroupingPanelBackColorGets or sets the background colour of the editor's filter and grouping pane.
GroupItemsWhenInMultiColumnDisplayModeGets or sets whether the editor's multi-column drop-down opens with its rows grouped under headings.
GroupMultiColumnDisplayModeDataBasedOnThisColumnGets or sets the column the editor's multi-column drop-down groups its rows by.
HeadersToDisplayGets or sets the heading text of each column of the editor's multi-column drop-down.
MultiColumnDropDownSizeGets or sets the size of the editor's multi-column drop-down.
MultiColumnDropDownWindowConfigurationGets or sets the header, footer and heading settings of the editor's multi-column drop-down.
MultiColumnDropListBackColorGets or sets the background colour of the rows in the editor's multi-column drop-down.
MultiColumnDropListFontGets or sets the font of the rows in the editor's multi-column drop-down.
MultiColumnDropListForeColorGets or sets the colour of the text in the rows of the editor's multi-column drop-down.
MultiColumnDropListGridLinesGets or sets whether lines are drawn between the rows and columns of the editor's multi-column drop-down.
MultiColumnDropListHoverSelectionGets or sets whether a row of the editor's multi-column drop-down is highlighted when the pointer rests on it.
MultiColumnDropListWindowIsResizableGets or sets whether the user can resize the editor's multi-column drop-down by dragging its edges.
ShouldAllowDragDropOfColumnsGets or sets whether the user can drag the headings of the editor's multi-column drop-down to reorder its columns.
ShowFilterOptionsInMultiColumnModeGets or sets whether the editor's multi-column drop-down has a filter and grouping pane at its foot.
Methods
CloneCreates a copy of the column with all its settings, as the designer and the grid do when they copy a column.
GetOptimumWidthEstimates a size for the drop-down that would show every column and row of a table, from the length of the longest value in each column.

Constructors

BinaryComboBoxColumn

public BinaryComboBoxColumn() : base()

Initialises a new column whose cells are BinaryTreeListViewComboBoxCell cells, edited with a BinaryTextComboBox.

Properties

AlphaBlendingfactorForFilterAndGroupingPanelBackColor

public int AlphaBlendingfactorForFilterAndGroupingPanelBackColor

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

Value
A blend weight from 0 (the window colour) to 255 (the pane colour). The default is 135.

AutoCompleteBasedOnCompleteMatchWithAnItemInTheList

public bool AutoCompleteBasedOnCompleteMatchWithAnItemInTheList

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

Value
false (the default) for the first matching item; true for the last.
Remarks

Applies to the control's own completion, which runs only while AutoCompleteMode is None. See BinaryTextComboBox.AutoCompleteBasedOnCompleteMatchWithAnItemInTheList.

AutoCompleteIsCaseSensitive

public bool AutoCompleteIsCaseSensitive

Gets or sets whether the editor's own 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 false – unlike the combo box, whose default is true.

AutoCompleteMode

public AutoCompleteMode AutoCompleteMode

Gets or sets the framework's auto-completion mode for the editing combo box.

Value
One of the AutoCompleteMode values. The default is Append.
Remarks

Any mode other than None replaces the combo box's own completion; see BinaryTextComboBox.AutoComplete. The suggestions come from AutoCompleteSource.

AutoCompleteSource

public AutoCompleteSource AutoCompleteSource

Gets or sets where the framework's auto-completion takes its suggestions from.

Value
One of the AutoCompleteSource values. The default is ListItems, the items of the list.

CSVFileSaveAs

public string CSVFileSaveAs

Gets or sets the file the editor's "Export data to CSV" command writes to.

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

An empty value removes the command. See BinaryTextComboBox.CSVFileSaveAs.

ColumnWidths

public int[] ColumnWidths

Gets or sets the width of each column of the editor's multi-column drop-down.

Value
Widths in logical pixels, in the order the columns are shown; or null (the default) to size each column to its content.
Remarks

ColumnsToDisplay

public string[] ColumnsToDisplay

Gets or sets which columns of DataGridViewComboBoxColumn.DataSource the editor's multi-column drop-down shows, and in what order.

Value
Column names, or null (the default) for every column.
Remarks

ComboBoxControlFont

public Font ComboBoxControlFont

Gets or sets the font of the editing combo box's text area.

Value
The font. The default is Control.DefaultFont.
Remarks

ComboBoxControlFontIsSameAsDropListWindowFont

public bool ComboBoxControlFontIsSameAsDropListWindowFont

Gets or sets whether the editing combo box uses the drop-down's row font (MultiColumnDropListFont) in place of ComboBoxControlFont.

Value
true to use one font for both. The default is false.

CustomComparerImplementor

public IComparer CustomComparerImplementor

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

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

CustomDropDownWindowLocationPoint

public Point CustomDropDownWindowLocationPoint

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

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

DropDownStyle

public ComboBoxStyle DropDownStyle

Gets or sets whether the user can type in the editing combo box, or only pick from its list.

Value
DropDown (the default) to allow typing, or DropDownList. Simple is not supported.

DropDownWindowBorderColor

public Color DropDownWindowBorderColor

Gets or sets the colour of the editing combo box's border and of the outline round its drop-down button.

Value
The border colour. The default is SystemColors.ControlDarkDark.
Remarks

Despite the name, this colours the editor itself, not its drop-down: it becomes the editor's BinaryComboBox.CustomControlBorderColor.

DropDownWindowDisplayOrientation

public Binarymission.WinForms.Controls.ListControls.DropDownWindowDisplayOrientation DropDownWindowDisplayOrientation

Gets or sets which way the editor's multi-column drop-down extends from the cell: 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

DropDownWindowPaintingColor

public Color DropDownWindowPaintingColor

Gets or sets the accent colour of the editing combo box – its drop-down button, highlighted item and the multi-column drop-down's accents.

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

DropStyleIsMultiColumn

public bool DropStyleIsMultiColumn

Gets or sets whether the column's cells open a multi-column drop-down listing every column of DataGridViewComboBoxColumn.DataSource, instead of the ordinary list.

Value
true for the multi-column drop-down. The default is false.
Remarks

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.
Remarks

EnableDrawingHeaderFooterWhenInMultiColumnMode

public bool EnableDrawingHeaderFooterWhenInMultiColumnMode

Gets or sets whether the editor's multi-column drop-down is framed by the header and footer bands set up in MultiColumnDropDownWindowConfiguration.

Value
true to draw the header and footer. The default is false.

EnableUserColumnResizing

public bool EnableUserColumnResizing

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

Value
true to allow resizing. The default is true.

FilterAndGroupingPanelBackColor

public Color FilterAndGroupingPanelBackColor

Gets or sets the background colour of the editor's filter and grouping pane.

Value
The pane's colour, or Color.Empty (the default) for the accent colour.
Remarks

GroupItemsWhenInMultiColumnDisplayMode

public bool GroupItemsWhenInMultiColumnDisplayMode

Gets or sets whether the editor's multi-column drop-down opens with its rows grouped under headings.

Value
true to open grouped. The default is false.
Remarks

GroupMultiColumnDisplayModeDataBasedOnThisColumn

public int GroupMultiColumnDisplayModeDataBasedOnThisColumn

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

Value
The zero-based position of the column in the drop-down. The default is 0.

HeadersToDisplay

public string[] HeadersToDisplay

Gets or sets the heading text of each column of the editor's multi-column drop-down.

Value
One heading per column shown, or null (the default) for the column names.
Remarks

Must have as many entries as ColumnsToDisplay, or an IndexOutOfRangeException is thrown when a cell starts editing in multi-column mode; see BinaryTextComboBox.HeadersToDisplay.

MultiColumnDropDownSize

public Size MultiColumnDropDownSize

Gets or sets the size of the editor's multi-column drop-down.

Value
The size in logical pixels. The default is 150 by 125; Size.Empty sizes the drop-down to its columns.
Remarks

The editing combo box scales the size to the display and keeps the window on the screen; see BinaryTextComboBox.MultiColumnDropDownSize. A size the user drags the window to is kept by the editor, which the grid shares between the column's cells, until the next cell starts editing.

MultiColumnDropDownWindowConfiguration

public MultiColumnDropDownWindowConfiguration MultiColumnDropDownWindowConfiguration

Gets or sets the header, footer and heading settings of the editor's multi-column drop-down.

Value
The settings. The default is an instance with its own defaults; change its properties rather than replacing it.
Remarks

Copied to the editing combo box each time a cell starts editing. In the designer the settings expand in the Properties window and are saved with the form.

MultiColumnDropListBackColor

public Color MultiColumnDropListBackColor

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

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

MultiColumnDropListFont

public Font MultiColumnDropListFont

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

Value
The font. The default is Control.DefaultFont, which means "use the cell's font".
Remarks

While the property holds its default font object, the editor uses the font of the cell being edited instead, so the drop-down matches the grid. Assign another font to override it.

MultiColumnDropListForeColor

public Color MultiColumnDropListForeColor

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

Value
The text colour. The default is SystemColors.WindowText.

MultiColumnDropListGridLines

public bool MultiColumnDropListGridLines

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

Value
true to draw grid lines. The default is true.

MultiColumnDropListHoverSelection

public bool MultiColumnDropListHoverSelection

Gets or sets whether a row of the editor's multi-column drop-down is highlighted when the pointer rests on it.

Value
true to highlight on hover. The default is false.

MultiColumnDropListWindowIsResizable

public bool MultiColumnDropListWindowIsResizable

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

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

ShouldAllowDragDropOfColumns

public bool ShouldAllowDragDropOfColumns

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

Value
true to allow reordering. The default is true – unlike the combo box, whose default is false.
Remarks

ShowFilterOptionsInMultiColumnMode

public bool ShowFilterOptionsInMultiColumnMode

Gets or sets whether the editor's multi-column drop-down has a filter and grouping pane at its foot.

Value
true to include the pane. The default is false – unlike the combo box, whose default is true.
Remarks

Methods

Clone

public override object Clone()

Creates a copy of the column with all its settings, as the designer and the grid do when they copy a column.

Returns

A new BinaryComboBoxColumn with the same settings.

Remarks

Reference-type settings are shared, not duplicated: the copy uses the same MultiColumnDropDownWindowConfiguration object, the same arrays and the same comparer as the original, so changing one of those objects changes both columns.

GetOptimumWidth

public Size GetOptimumWidth(DataTable theTable)

Estimates a size for the drop-down that would show every column and row of a table, from the length of the longest value in each column.

Parameters
theTable
The table the drop-down will list.
Returns

An estimated width and height in pixels; Size.Empty when theTable is null.

Remarks

The width allows for the longest text (or column name) in each column at the size of the default font, and the height for one line of MultiColumnDropListFont per row plus the heading, with room for the frame. It is a quick estimate from character counts, not a measurement, and is not scaled to the display.

The column does not call it. Pass the result to MultiColumnDropDownSize if it suits; the editing combo box sizes its drop-down to the columns by itself when given Size.Empty.