System.Windows.Forms.DataGridView.CellValueChanged Event

Occurs when the value of a cell changes.

Syntax

public event DataGridViewCellEventHandler CellValueChanged

Remarks

The DataGridView.CellValueChanged event occurs when the user-specified value is committed, which typically occurs when focus leaves the cell.

In the case of check box cells, however, you will typically want to handle the change immediately. 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.

Rows in the control are not automatically sorted when a cell value is changed. To sort the control when the user modifies a cell, call the erload:System.Windows.Forms.DataGridView.Sort method in a DataGridView.CellValueChanged event handler.

For more information about handling events, see Consuming Events.

Requirements

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