DataRow.EndEdit 메서드

정의

행에서 수행 중인 편집을 끝냅니다.

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

예외

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

제약 조건을 위반하여 편집한 경우

행이 테이블에 속해 있으며 편집 중에 읽기 전용 열의 값을 변경하려고 한 경우

편집 중에 AllowDBNull이 false인 열에 null 값을 지정하려고 한 경우

예제

다음 예제에서는 유효성 검사 함수가 EndEdit true를 반환하는 경우 메서드를 DataRow 사용하여 값 편집을 종료합니다.

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

설명

설정 하는 경우는 속성 예외가 발생 RowChanging 하는 경우 예외가 생성 됩니다는 이벤트입니다.

적용 대상

추가 정보