BindingManagerBase.EndCurrentEdit メソッド
派生クラスでオーバーライドされると、現在の編集を終了します。
Public MustOverride Sub EndCurrentEdit()
[C#]
public abstract void EndCurrentEdit();
[C++]
public: virtual void EndCurrentEdit() = 0;
[JScript]
public abstract function EndCurrentEdit();
解説
このメソッドは、データ ソースが IEditableObject インターフェイスを実装している場合にだけサポートされます。この場合、変更内容は保存されます。オブジェクトが IEditableObject インターフェイスを実装していない場合は、データへの変更は保存されません。
使用例
[Visual Basic, C#, C++] 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
[C#]
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"]);
}
[C++]
private:
void CancelEdit() {
// Gets the CurrencyManager which is returned when the
// data source is a DataView.
BindingManagerBase* myMgr =
dynamic_cast<CurrencyManager*>(BindingContext->Item[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(S"Original: {0}", tempRowView->Item[S"myCol"]);
tempRowView->Item[S"myCol"] = S"These changes will be discarded";
Console::WriteLine(S"Edit: {0}", tempRowView->Item[S"myCol"]);
myMgr->CancelCurrentEdit();
Console::WriteLine(S"After CanceCurrentlEdit: {0}",
tempRowView->Item[S"myCol"]);
}
void EndEdit() {
// Gets the CurrencyManager which is returned when the
// data source is a DataView.
BindingManagerBase* myMgr =
dynamic_cast<CurrencyManager*>(BindingContext->Item[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(S"Original: {0}", tempRowView->Item[S"myCol"]);
tempRowView->Item[S"myCol"] = S"These changes will be kept";
Console::WriteLine(S"Edit: {0}", tempRowView->Item[S"myCol"]);
myMgr->EndCurrentEdit();
Console::WriteLine(S"After EndCurrentEdit: {0}",
tempRowView->Item[S"myCol"]);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
BindingManagerBase クラス | BindingManagerBase メンバ | System.Windows.Forms 名前空間 | CancelCurrentEdit