DataGrid.CancelEdit Method

Causes the data grid to cancel the current edit, restore the original value, and exit editing mode.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

Public Function CancelEdit As Boolean

Return Value

Type: System.Boolean
true if the cancellation was successful; otherwise, false.

Calling CancelEdit is equivalent to calling CancelEdit with an editingUnit value of Row.

By default, you can edit items directly in the DataGrid. You manually cancel a cell edit by pressing ESC one time, and cancel all edits in a row by pressing ESC two times. To guarantee that edits can be committed and canceled correctly, the objects in the DataGrid must implement the IEditableObject interface. Alternatively, you can set the IsReadOnly property to true to disable editing in the DataGrid.


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions