Cancels the current edit on the row.
[Visual Basic] Public Sub CancelEdit() [C#] public void CancelEdit(); [C++] public: void CancelEdit(); [JScript] public function CancelEdit();
Exception Type | Condition |
---|---|
InRowChangingEventException | The method was called inside the RowChanging event. |
See the BeginEdit method for more details.
The following example edits the value of one column in the last row of a System.WinForms.DataGrid control. The example uses the BeginEdit, EndEdit, and AcceptChanges methods to programmatically edit the column's value and commit the change to the row, and finally to the table itself.
[Visual Basic]
Private Sub EditAndAccept() Dim t As DataTable t = DataSet1.Tables(0) Dim myrow As DataRow myRow = t.Rows(t.Rows.Count - 1) myrow.BeginEdit myrow(1) = Edit1.Text myrow.EndEdit myrow.AcceptChanges t.AcceptChanges End Sub
DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | DataViewRowState | EndEdit | HasVersion | Item | RowState