ComboBoxColumn
Represents a column of DataGridViewComboBoxCell objects.
Last updated
Represents a column of DataGridViewComboBoxCell objects.
Last updated
The DataGridViewComboBoxColumn class is a specialized type of DataGridViewColumn used to logically host cells that enable users to select values from a list of choices. A DataGridViewComboBoxColumn has an associated DataGridViewComboBoxCell in every DataGridViewRow that intersects it.
You can populate the cells manually by setting their Value properties. Alternatively, you can bind the column to the data source indicated by the DataGridView.DataSource property. If the DataGridView is bound to a database table, set the column DataPropertyName property to the name of a column in the table. If the DataGridView is bound to a collection of objects, set the DataPropertyName property to the name of an object property.
You can populate the column drop-down list manually by adding values to the Items collection. Alternatively, you can bind the drop-down list to its own data source by setting the column DataSource property. If the values are objects in a collection or records in a database table, you must also set the DisplayMember and ValueMember properties. The DisplayMember property indicates which object property or database column provides the values that are displayed in the drop-down list. The ValueMember property indicates which object property or database column is used to set the cell Value property.
For a full list of properties, methods and events see the API documentation.
The DataGridViewComboBoxColumn features several different drop down presets:
Simple: The list is always visible and that the text portion is editable. The user can enter a new value or can select an existing value in the list.
DropDown: The list is displayed by clicking the down arrow, or pressing either the Down, Alt+Down or Alt+Up keys, and that the text portion is editable. The user can enter a new value or select an existing value in the list.
DropDownList: The list is displayed by clicking the down arrow, or pressing either the Down, Alt+Down or Alt+Up keys, and that the text portion is not editable. The user cannot enter a new value and can only select a value already in the list.