BindingManagerBase.EndCurrentEdit 메서드

정의

파생 클래스에서 재정의되면 현재 편집을 끝냅니다.

public:
 abstract void EndCurrentEdit();
public abstract void EndCurrentEdit ();
abstract member EndCurrentEdit : unit -> unit
Public MustOverride Sub EndCurrentEdit ()

예제

다음 코드 예제에서는 메서드와 메서드를 CancelCurrentEdit EndCurrentEdit 모두 보여 줍니다. 메서드를 CancelCurrentEdit 호출하면 데이터에 대한 변경 내용이 삭제됩니다. 메서드를 EndCurrentEdit 호출하면 변경 내용이 유지됩니다.

private:
   void CancelEdit()
   {
      // Gets the CurrencyManager which is returned when the
      // data source is a DataView.
      BindingManagerBase^ myMgr = dynamic_cast<CurrencyManager^>(BindingContext[ myDataView ]);

      // Gets the current row and changes a value. Then cancels the
      // edit and thereby discards the changes.
      DataRowView^ tempRowView = dynamic_cast<DataRowView^>(myMgr->Current);
      Console::WriteLine( "Original: {0}", tempRowView[ "myCol" ] );
      tempRowView[ "myCol" ] = "These changes will be discarded";
      Console::WriteLine( "Edit: {0}", tempRowView[ "myCol" ] );
      myMgr->CancelCurrentEdit();
      Console::WriteLine( "After CanceCurrentlEdit: {0}", tempRowView[ "myCol" ] );
   }

   void EndEdit()
   {
      // Gets the CurrencyManager which is returned when the
      // data source is a DataView.
      BindingManagerBase^ myMgr = dynamic_cast<CurrencyManager^>(BindingContext[ myDataView ]);
      
      // Gets the current row and changes a value. Then ends the
      // edit and thereby keeps the changes.
      DataRowView^ tempRowView = dynamic_cast<DataRowView^>(myMgr->Current);
      Console::WriteLine( "Original: {0}", tempRowView[ "myCol" ] );
      tempRowView[ "myCol" ] = "These changes will be kept";
      Console::WriteLine( "Edit: {0}", tempRowView[ "myCol" ] );
      myMgr->EndCurrentEdit();
      Console::WriteLine( "After EndCurrentEdit: {0}", tempRowView[ "myCol" ] );
   }
private void CancelEdit()
{
    // Gets the CurrencyManager which is returned when the
    // data source is a DataView.
    BindingManagerBase myMgr =
        (CurrencyManager) BindingContext[myDataView];

    // Gets the current row and changes a value. Then cancels the
    // edit and thereby discards the changes.
    DataRowView tempRowView = (DataRowView) myMgr.Current;
    Console.WriteLine("Original: {0}", tempRowView["myCol"]);
    tempRowView["myCol"] = "These changes will be discarded";
    Console.WriteLine("Edit: {0}", tempRowView["myCol"]);
    myMgr.CancelCurrentEdit();
    Console.WriteLine("After CanceCurrentlEdit: {0}",
        tempRowView["myCol"]);
}

private void EndEdit()
{
    // Gets the CurrencyManager which is returned when the
    // data source is a DataView.
    BindingManagerBase myMgr =
        (CurrencyManager) BindingContext[myDataView];

    // Gets the current row and changes a value. Then ends the
    // edit and thereby keeps the changes.
    DataRowView tempRowView = (DataRowView) myMgr.Current;
    Console.WriteLine("Original: {0}", tempRowView["myCol"]);
    tempRowView["myCol"] = "These changes will be kept";
    Console.WriteLine("Edit: {0}", tempRowView["myCol"]);
    myMgr.EndCurrentEdit();
    Console.WriteLine("After EndCurrentEdit: {0}",
        tempRowView["myCol"]);
}
Private Sub CancelEdit()
    ' Gets the CurrencyManager which is returned when the 
    ' data source is a DataView.
    Dim myMgr As BindingManagerBase = _
    CType(BindingContext(myDataView), CurrencyManager)

    ' Gets the current row and changes a value. Then cancels the 
    ' edit and thereby discards the changes.
    Dim tempRowView As DataRowView = _
    CType(myMgr.Current, DataRowView)
    Console.WriteLine("Original: {0}", tempRowView("myCol"))
    tempRowView("myCol") = "These changes will be discarded"
    Console.WriteLine("Edit: {0}", tempRowView("myCol"))
    myMgr.CancelCurrentEdit()
    Console.WriteLine("After CanceCurrentlEdit: {0}", _
    tempRowView("myCol"))
End Sub

Private Sub EndEdit()
    ' Gets the CurrencyManager which is returned when the 
    ' data source is a DataView.
    Dim myMgr As BindingManagerBase = _
    CType(BindingContext(myDataView), CurrencyManager)

    ' Gets the current row and changes a value. Then ends the 
    ' edit and thereby keeps the changes.
    Dim tempRowView As DataRowView = _
    CType(myMgr.Current, DataRowView)
    Console.WriteLine("Original: {0}", tempRowView("myCol"))
    tempRowView("myCol") = "These changes will be kept"
    Console.WriteLine("Edit: {0}", tempRowView("myCol"))
    myMgr.EndCurrentEdit()
    Console.WriteLine("After EndCurrentEdit: {0}", _
    tempRowView("myCol"))
End Sub

설명

이 메서드는 데이터 원본이 인터페이스를 구현하는 경우에만 지원됩니다 IEditableObject . 이 경우 변경 내용이 저장됩니다. 개체가 인터페이스를 IEditableObject 구현하지 않으면 데이터에 대한 변경 내용이 저장되지 않습니다.

적용 대상

추가 정보