DataGridView::CellValueChanged Event

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Occurs when the value of a cell changes.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
event DataGridViewCellEventHandler^ CellValueChanged {
	void add(DataGridViewCellEventHandler^ value);
	void remove(DataGridViewCellEventHandler^ value);
}

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 method and pass in the 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 Sort method in a CellValueChanged event handler.

For more information about handling events, see NIB: Consuming Events.

The following code example demonstrates how to use the CellValueChanged event to update the values in a balance column of a DataGridView. This example is part of a larger example available in the SelectionChanged event.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: