System.Windows.Forms.DataGridViewComboBoxCell Class

Displays a combo box in a System.Windows.Forms.DataGridView control.

See Also: DataGridViewComboBoxCell Members

Syntax

public class DataGridViewComboBoxCell : DataGridViewCell

Remarks

The System.Windows.Forms.DataGridViewComboBoxCell class is a specialized type of System.Windows.Forms.DataGridViewCell used to display a combo box control, which is an editing field combined with a list selection field. The currently selected System.Windows.Forms.DataGridViewComboBoxCell hosts a System.Windows.Forms.DataGridViewComboBoxEditingControl in which the user can change the cell's value, assuming the cell's DataGridViewCell.ReadOnly property is set to false.

Unlike the System.Windows.Forms.ComboBox control, the System.Windows.Forms.DataGridViewComboBoxCell does not have ComboBox.SelectedIndex and ListControl.SelectedValue properties. Instead, selecting a value from a drop-down list sets the cell DataGridViewCell.Value property.

The System.Windows.Forms.DataGridViewComboBoxColumn is the column type specialized to hold cells of this type. By default, the DataGridViewComboBoxColumn.CellTemplate is initialized to a new System.Windows.Forms.DataGridViewComboBoxCell. To pattern the cells within a column after an existing System.Windows.Forms.DataGridViewComboBoxCell, set the column's DataGridViewComboBoxColumn.CellTemplate property to the cell to use as a pattern.

The cell-related properties of the column are wrappers for the similarly-named properties of the template cell. Changing the property values of the template cell will affect only cells based on the template that are added after the change. Changing the cell-related property values of the column, however, will update the template cell and all other cells in the column, and refresh the column display if necessary.

You will typically work with the System.Windows.Forms.DataGridViewComboBoxColumn type unless you want to override column values for specific cells. The guidelines described in the System.Windows.Forms.DataGridViewComboBoxColumn class overview topic for populating the drop-down list applies to both cell and column instances.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0