Ends the edit occurring on the row.
[Visual Basic] Public Sub EndEdit() [C#] public void EndEdit(); [C++] public: void EndEdit(); [JScript] public function EndEdit();
Exception Type | Condition |
---|---|
InRowChangingEventException | The method was called inside the RowChanging event. |
ConstraintException | The edit broke a constraint. |
ReadOnlyException | The row belongs to the table and the edit tried to change the value of a read-only column. |
NoNullAllowedException | The edit tried to put a null value into a column where AllowNull is false. |
When setting the property, an exception will be thrown if an exception occurs in the RowChanging event.
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 ' Set the variable to the last row in the table. myRow = t.Rows(t.Rows.Count - 1) myrow.BeginEdit ' Set the value to the Text property of an Edit control. myrow(1) = Edit1.Text ' End the edit operation. myrow.EndEdit ' Accept changes on the row. myrow.AcceptChanges ' Accept changes on the table. t.AcceptChanges End Sub
DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | AllowNull | BeginEdit | CancelEdit | HasVersion | Item | RowState