Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Bricht beim Überschreiben in einer abgeleiteten Klasse den aktuellen Bearbeitungsvorgang ab.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public MustOverride Sub CancelCurrentEdit
'Usage
Dim instance As BindingManagerBase
instance.CancelCurrentEdit
public abstract void CancelCurrentEdit ()
public:
virtual void CancelCurrentEdit () abstract
public abstract void CancelCurrentEdit ()
public abstract function CancelCurrentEdit ()
Hinweise
Diese Methode wird nur unterstützt, wenn die Datenquelle die IEditableObject-Schnittstelle implementiert. Wenn das Objekt die IEditableObject-Schnittstelle nicht implementiert, werden Änderungen der Daten nicht verworfen.
Durch Aufrufen der CancelCurrentEdit-Methode tritt das Format-Ereignis ein.
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
AddNew
EndCurrentEdit
CancelCurrentEdit
IEditableObject