Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.)
Gets the column index of the cell that needs to be validated.
Gets the formatted contents of the cell that needs to be validated.
Gets the row index of the cell that needs to be validated.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
The DataGridView.CellValidating event lets you cancel changes to the current cell when the new value is not valid. Use the FormattedValue property to determine the current value. To determine the state of the current cell, use the RowIndex and ColumnIndex properties to access the cell through the DataGridView.Rows collection. To cancel the change, set the Cancel property to true.
When this event is canceled in data-bound mode, the new value is not pushed to the underlying data source. When this event is canceled in virtual mode, the DataGridView.CellValuePushed event will not be raised.
The following code example handles the CellValidating event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the VirtualMode reference topic.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.