DataGrid.CommitEdit Method (DataGridEditingUnit, Boolean)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Causes the data grid to commit the current edit to the data source, and optionally exit editing mode.

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

Syntax

'Declaration
Public Function CommitEdit ( _
    editingUnit As DataGridEditingUnit, _
    exitEditingMode As Boolean _
) As Boolean
public bool CommitEdit(
    DataGridEditingUnit editingUnit,
    bool exitEditingMode
)

Parameters

  • exitEditingMode
    Type: System.Boolean
    true to exit editing mode; otherwise, false.

Return Value

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

Remarks

By default, you can edit items directly in the DataGrid. A cell-level edit is committed when you move to another cell in the same row. All edits in a row are committed when you press ENTER or move to another row. 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.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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