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. 롤백할 수 있습니다도 변경 내용이 호출 하 여 RejectChanges 부모에 DataTable입니다.You can also roll back changes by calling RejectChanges on the parent DataTable.

적용 대상

추가 정보