BindingManagerBase.CancelCurrentEdit メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


このメソッドは、データ ソースが IEditableObject インターフェイスを実装している場合にだけサポートされます。オブジェクトが IEditableObject インターフェイスを実装していない場合は、データへの変更は破棄されません。

CancelCurrentEdit メソッドと EndCurrentEdit メソッドのコード例を次に示します。CancelCurrentEdit メソッドを呼び出すと、データに加えた変更は破棄されます。EndCurrentEdit メソッドを呼び出すと、変更は保持されます。
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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


BindingManagerBase クラス
BindingManagerBase メンバ
System.Windows.Forms 名前空間
AddNew
EndCurrentEdit
CancelCurrentEdit
IEditableObject
Weblioに収録されているすべての辞書からBindingManagerBase.CancelCurrentEdit メソッドを検索する場合は、下記のリンクをクリックしてください。

- BindingManagerBase.CancelCurrentEdit メソッドのページへのリンク