IEditableCollectionView.CancelEdit 方法

定義

結束編輯交易,並在可能的情況下還原該項目的原始值。

public:
 void CancelEdit();
public void CancelEdit();
abstract member CancelEdit : unit -> unit
Public Sub CancelEdit ()

範例

以下範例將檢查 CanCancelEdit 在呼叫 CancelEdit前,編輯項目的原始值是否能被還原。 如果數值無法還原,你必須提供額外的邏輯來還原。 如果可以,當範例呼叫 CancelEdit時,值會被恢復。 關於整個範例,請參見 「透過使用 IEditableCollectionView 變更集合範例」。

// If the objects in the collection can discard pending 
// changes, calling IEditableCollectionView.CancelEdit
// will revert the changes. Otherwise, you must provide
// your own logic to revert the changes in the object.

if (!editableCollectionView.CanCancelEdit)
{
    // Provide logic to revert changes.
}

editableCollectionView.CancelEdit();
' If the objects in the collection can discard pending 
' changes, calling IEditableCollectionView.CancelEdit
' will revert the changes. Otherwise, you must provide
' your own logic to revert the changes in the object.

If Not editableCollectionView.CanCancelEdit Then
    ' Provide logic to revert changes.
End If

editableCollectionView.CancelEdit()

備註

CancelEdit 設定 CurrentEditItem 為 , null 導致集合檢視退出編輯狀態。 若 CanCancelEdittrueCancelEdit 則 也會恢復編輯物件的原始值。

適用於