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 會將 設定 CurrentEditItemnull ,並導致集合檢視結束編輯狀態。 如果 CanCancelEdittrueCancelEdit 則也會還原已編輯物件的原始值。

適用於