BindingManagerBase.EndCurrentEdit メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
派生クラスでオーバーライドされると、現在の編集を終了します。
public:
abstract void EndCurrentEdit();
public abstract void EndCurrentEdit ();
abstract member EndCurrentEdit : unit -> unit
Public MustOverride Sub EndCurrentEdit ()
例
次のコード例は、メソッドとメソッドの両方をCancelCurrentEditEndCurrentEdit示しています。 メソッドを 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 実装していない場合、データに加えられた変更は保存されません。