Freigeben über


BindingManagerBase.EndCurrentEdit-Methode

Beendet beim Überschreiben in einer abgeleiteten Klasse den aktuellen Bearbeitungsvorgang.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public MustOverride Sub EndCurrentEdit
'Usage
Dim instance As BindingManagerBase

instance.EndCurrentEdit
public abstract void EndCurrentEdit ()
public:
virtual void EndCurrentEdit () abstract
public abstract void EndCurrentEdit ()
public abstract function EndCurrentEdit ()

Hinweise

Diese Methode wird nur unterstützt, wenn die Datenquelle die IEditableObject-Schnittstelle implementiert. In diesem Fall werden Änderungen gespeichert. Wenn das Objekt die IEditableObject-Schnittstelle nicht implementiert, werden Änderungen der Daten nicht gespeichert.

Beispiel

Im folgenden Codebeispiel werden die CancelCurrentEdit-Methode und die EndCurrentEdit-Methode veranschaulicht . Bei einem Aufruf der CancelCurrentEdit-Methode werden an den Daten vorgenommene Änderungen verworfen. Bei einem Aufruf der EndCurrentEdit-Methode werden die Änderungen beibehalten.

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
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:
   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)(get_BindingContext().get_Item(myDataView));

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

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

    // Gets the current row and changes a value. Then ends the 
    // edit and thereby keeps the changes.
    DataRowView tempRowView = (DataRowView)(myMgr.get_Current());
    Console.WriteLine("Original: {0}", tempRowView.get_Item("myCol"));
    tempRowView.set_Item("myCol", "These changes will be kept");
    Console.WriteLine("Edit: {0}", tempRowView.get_Item("myCol"));
    myMgr.EndCurrentEdit();
    Console.WriteLine("After EndCurrentEdit: {0}", 
        tempRowView.get_Item("myCol"));
} //EndEdit

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

BindingManagerBase-Klasse
BindingManagerBase-Member
System.Windows.Forms-Namespace
CancelCurrentEdit