DataRowView.CancelEdit DataRowView.CancelEdit DataRowView.CancelEdit DataRowView.CancelEdit Method

定義

編集プロシージャをキャンセルします。Cancels an edit procedure.

public:
 virtual void CancelEdit();
public void CancelEdit ();
abstract member CancelEdit : unit -> unit
override this.CancelEdit : unit -> unit
Public Sub CancelEdit ()

実装

次の例の行の編集、DataViewします。The following example edits a row in a DataView. CancelEdit検証が失敗した場合、変更をキャンセルするメソッドが呼び出されます。The CancelEdit method is called to cancel the changes if the validation fails.

private void EditDataRowView(DataRowView rowView, 
    string columnToEdit) 
{
    rowView.BeginEdit();
    rowView[columnToEdit] = textBox1.Text;

    // Validate the input with a function.
    if (ValidateCompanyName(rowView[columnToEdit]))
        rowView.EndEdit();   
    else
        rowView.CancelEdit();
}

private bool ValidateCompanyName(object valuetoCheck) 
{
    // Insert code to validate the value.
    return true;
}
Private Sub EditDataRowView(rowView As DataRowView, _
    columnToEdit As String)
    rowView.BeginEdit()
    rowView(columnToEdit) = textBox1.Text

    ' Validate the input with a function.
    If ValidateCompanyName(rowView(columnToEdit)) Then
        rowView.EndEdit()
    Else
        rowView.CancelEdit()
    End If
End Sub
     
Private Function ValidateCompanyName( _
    valuetoCheck As Object) As Boolean
    ' Insert code to validate the value.
    Return True
End Function

注釈

呼び出した後CancelEdit、行に対するすべての変更はロールバックされます。After calling CancelEdit, all changes to the row are rolled back. 戻すことができますも変更を呼び出してRejectChangesDataTableします。You can also roll back changes by calling RejectChanges on the parent DataTable.

適用対象

こちらもご覧ください