BinaryComboBoxColumn
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 | |
|---|---|
BinaryComboBoxColumn | Initialises a new column whose cells are BinaryTreeListViewComboBoxCell cells, edited with a
BinaryTextComboBox. |
| Properties | |
AlphaBlendingfactorForFilterAndGroupingPanelBackColor | Gets or sets how strongly the pane colour shows when the filter and grouping pane's colour is blended. |
AutoCompleteBasedOnCompleteMatchWithAnItemInTheList | Gets or sets which item the editor's own completion uses when several start with the typed text: the first, or the last. |
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. |
AutoCompleteMode | Gets or sets the framework's auto-completion mode for the editing combo box. |
AutoCompleteSource | Gets or sets where the framework's auto-completion takes its suggestions from. |
CSVFileSaveAs | Gets or sets the file the editor's "Export data to CSV" command writes to. |
ColumnWidths | Gets or sets the width of each column of the editor's multi-column drop-down. |
ColumnsToDisplay | Gets or sets which columns of DataGridViewComboBoxColumn.DataSource the editor's multi-column drop-down
shows, and in what order. |
ComboBoxControlFont | Gets or sets the font of the editing combo box's text area. |
ComboBoxControlFontIsSameAsDropListWindowFont | Gets or sets whether the editing combo box uses the drop-down's row font (MultiColumnDropListFont) in
place of ComboBoxControlFont. |
CustomComparerImplementor | Gets or sets a comparison of your own for sorting the rows of the editor's multi-column drop-down. |
CustomDropDownWindowLocationPoint | Gets or sets a fixed screen position for the top-left corner of the editor's multi-column drop-down. |
DropDownStyle | Gets or sets whether the user can type in the editing combo box, or only pick from its list. |
DropDownWindowBorderColor | Gets or sets the colour of the editing combo box's border and of the outline round its drop-down button. |
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. |
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. |
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. |
EnableAlphaBlendingForFilterAndGroupingPanelBackColor | Gets or sets whether the filter and grouping pane's colour is blended with the window colour into a paler tint. |
EnableDrawingHeaderFooterWhenInMultiColumnMode | Gets or sets whether the editor's multi-column drop-down is framed by the header and footer bands set up in
MultiColumnDropDownWindowConfiguration. |
EnableUserColumnResizing | Gets or sets whether the user can drag the edges of the editor's drop-down headings to resize its columns. |
FilterAndGroupingPanelBackColor | Gets or sets the background colour of the editor's filter and grouping pane. |
GroupItemsWhenInMultiColumnDisplayMode | Gets or sets whether the editor's multi-column drop-down opens with its rows grouped under headings. |
GroupMultiColumnDisplayModeDataBasedOnThisColumn | Gets or sets the column the editor's multi-column drop-down groups its rows by. |
HeadersToDisplay | Gets or sets the heading text of each column of the editor's multi-column drop-down. |
MultiColumnDropDownSize | Gets or sets the size of the editor's multi-column drop-down. |
MultiColumnDropDownWindowConfiguration | Gets or sets the header, footer and heading settings of the editor's multi-column drop-down. |
MultiColumnDropListBackColor | Gets or sets the background colour of the rows in the editor's multi-column drop-down. |
MultiColumnDropListFont | Gets or sets the font of the rows in the editor's multi-column drop-down. |
MultiColumnDropListForeColor | Gets or sets the colour of the text in the rows of the editor's multi-column drop-down. |
MultiColumnDropListGridLines | Gets or sets whether lines are drawn between the rows and columns of the editor's multi-column drop-down. |
MultiColumnDropListHoverSelection | Gets or sets whether a row of the editor's multi-column drop-down is highlighted when the pointer rests on it. |
MultiColumnDropListWindowIsResizable | Gets or sets whether the user can resize the editor's multi-column drop-down by dragging its edges. |
ShouldAllowDragDropOfColumns | Gets or sets whether the user can drag the headings of the editor's multi-column drop-down to reorder its columns. |
ShowFilterOptionsInMultiColumnMode | Gets or sets whether the editor's multi-column drop-down has a filter and grouping pane at its foot. |
| Methods | |
Clone | Creates a copy of the column with all its settings, as the designer and the grid do when they copy a column. |
GetOptimumWidth | 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. |
Constructors
BinaryComboBoxColumn
Initialises a new column whose cells are BinaryTreeListViewComboBoxCell cells, edited with a
BinaryTextComboBox.
Properties
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
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;truefor the last.
Remarks
Applies to the control's own completion, which runs only while AutoCompleteMode is
None. See BinaryTextComboBox.AutoCompleteBasedOnCompleteMatchWithAnItemInTheList.
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
trueto match case exactly. The default isfalse– unlike the combo box, whose default istrue.
AutoCompleteMode
Gets or sets the framework's auto-completion mode for the editing combo box.
- Value
- One of the
AutoCompleteModevalues. The default isAppend.
Remarks
Any mode other than None replaces the combo box's own completion; see
BinaryTextComboBox.AutoComplete. The suggestions come from AutoCompleteSource.
AutoCompleteSource
Gets or sets where the framework's auto-completion takes its suggestions from.
- Value
- One of the
AutoCompleteSourcevalues. The default isListItems, the items of the list.
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
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
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
Gets or sets the font of the editing combo box's text area.
- Value
- The font. The default is
Control.DefaultFont.
Remarks
Ignored while ComboBoxControlFontIsSameAsDropListWindowFont is true.
ComboBoxControlFontIsSameAsDropListWindowFont
Gets or sets whether the editing combo box uses the drop-down's row font (MultiColumnDropListFont) in
place of ComboBoxControlFont.
- Value
trueto use one font for both. The default isfalse.
CustomComparerImplementor
Gets or sets a comparison of your own for sorting the rows of the editor's multi-column drop-down.
- Value
- An
IComparerthat compares twoListViewItemrows, ornull(the default) for the built-in comparison.
Remarks
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
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, orDropDownList.Simpleis not supported.
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
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.RightorDropDownWindowDisplayOrientation.Default. The default isDropDownWindowDisplayOrientation.Default.
Remarks
Use DropDownWindowDisplayOrientation.Left for a column near the right of the grid. See
BinaryTextComboBox.DropDownWindowDisplayOrientation.
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
It becomes the editor's BinaryTextComboBox.CustomPaintingColor.
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
truefor the multi-column drop-down. The default isfalse.
Remarks
EnableAlphaBlendingForFilterAndGroupingPanelBackColor
Gets or sets whether the filter and grouping pane's colour is blended with the window colour into a paler tint.
- Value
trueto blend. The default istrue.
Remarks
EnableUserColumnResizing
Gets or sets whether the user can drag the edges of the editor's drop-down headings to resize its columns.
- Value
trueto allow resizing. The default istrue.
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
Gets or sets whether the editor's multi-column drop-down opens with its rows grouped under headings.
- Value
trueto open grouped. The default isfalse.
Remarks
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
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
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.Emptysizes 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
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
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
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
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
Gets or sets whether lines are drawn between the rows and columns of the editor's multi-column drop-down.
- Value
trueto draw grid lines. The default istrue.
MultiColumnDropListHoverSelection
Gets or sets whether a row of the editor's multi-column drop-down is highlighted when the pointer rests on it.
- Value
trueto highlight on hover. The default isfalse.
MultiColumnDropListWindowIsResizable
Gets or sets whether the user can resize the editor's multi-column drop-down by dragging its edges.
- Value
truefor a resizable window. The default istrue.
ShouldAllowDragDropOfColumns
Gets or sets whether the user can drag the headings of the editor's multi-column drop-down to reorder its columns.
- Value
trueto allow reordering. The default istrue– unlike the combo box, whose default isfalse.
Remarks
ShowFilterOptionsInMultiColumnMode
Gets or sets whether the editor's multi-column drop-down has a filter and grouping pane at its foot.
- Value
trueto include the pane. The default isfalse– unlike the combo box, whose default istrue.
Remarks
Methods
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
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.