DataRow.CancelEdit 메서드

정의

행의 현재 편집을 취소합니다.

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

예외

RowChanging 이벤트 내부에서 메서드를 호출한 경우

예제

다음 예제에서는 컨트롤의 마지막 행에 있는 한 열의 값을 편집합니다 DataGrid . 이 예제에서는 , , EndEdit메서드를 사용하여 BeginEdit열의 값을 편집하고 변경 내용을 행에 커밋합니다.

private void AcceptOrReject(DataRow row)
{
    // Use a function to validate the row's values.
    // If the function returns true, end the edit;
    // otherwise cancel it.
    if(ValidateRow(row))
        row.EndEdit();
    else
        row.CancelEdit();
}

private bool ValidateRow(DataRow thisRow)
{
    bool isValid = true;
    // Insert code to validate the row values.
    // Set the isValid variable.
    return isValid;
}
 Private Sub AcceptOrReject(ByVal row As DataRow)
    ' Use a function to validate the row's values.
    ' If the function returns true, end the edit; 
    ' otherwise cancel it.
    If ValidateRow(row) Then
       row.EndEdit()
    Else
       row.CancelEdit()
    End If
End Sub
 
Private Function ValidateRow(ByVal row As DataRow) As Boolean
    Dim isValid As Boolean
    ' Insert code to validate the row values. 
    ' Set the isValid variable.
    ValidateRow = isValid
End Function

설명

자세한 내용은 BeginEdit 메서드를 참조하세요.

적용 대상

추가 정보