System.Windows.Forms.DataGridViewCheckBoxColumn Class

Hosts a collection of System.Windows.Forms.DataGridViewCheckBoxCell objects.

See Also: DataGridViewCheckBoxColumn Members


public class DataGridViewCheckBoxColumn : DataGridViewColumn


The System.Windows.Forms.DataGridViewCheckBoxColumn class is a specialized type of the System.Windows.Forms.DataGridViewColumn class used to logically host cells that indicate binary state. A System.Windows.Forms.DataGridViewCheckBoxColumn has an associated System.Windows.Forms.DataGridViewCheckBoxCell in every System.Windows.Forms.DataGridViewRow that intersects it. Each cell supplies a user interface (UI) that is similar to a System.Windows.Forms.CheckBox control.

The default sort mode for this column type is DataGridViewColumnSortMode.NotSortable.

Typically, check box cell values are intended either for storage, like any other data, or for performing bulk operations. If you want to respond immediately when users click a check box cell, you can handle the DataGridView.CellContentClick event, but this event occurs before the cell value is updated. If you need the new value at the time of the click, one option is to calculate what the expected value will be based on the current value. Another approach is to commit the change immediately, and handle the DataGridView.CellValueChanged event to respond to it. To commit the change when the cell is clicked, you must handle the DataGridView.CurrentCellDirtyStateChanged event. In the handler, if the current cell is a check box cell, call the DataGridView.CommitEdit(DataGridViewDataErrorContexts) method and pass in the DataGridViewDataErrorContexts.Commit value.


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