BindingManagerBase.CancelCurrentEdit Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Bricht beim Überschreiben in einer abgeleiteten Klasse den aktuellen Bearbeitungsvorgang ab.
public:
abstract void CancelCurrentEdit();
public abstract void CancelCurrentEdit ();
abstract member CancelCurrentEdit : unit -> unit
Public MustOverride Sub CancelCurrentEdit ()
Beispiele
Im folgenden Codebeispiel werden sowohl die CancelCurrentEdit -Methode als auch die EndCurrentEdit -Methode veranschaulicht. Wenn Sie die CancelCurrentEdit Methoden aufrufen, werden änderungen, die an den Daten vorgenommen wurden, verworfen. Wenn Sie die EndCurrentEdit -Methode aufrufen, werden die Änderungen beibehalten.
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
Hinweise
Diese Methode wird nur unterstützt, wenn die Datenquelle die IEditableObject -Schnittstelle implementiert. Wenn das -Objekt die IEditableObject -Schnittstelle nicht implementiert, werden an den Daten vorgenommene Änderungen nicht verworfen.
Wenn Sie die CancelCurrentEdit -Methode aufrufen, tritt das Format Ereignis auf.