IEditableCollectionView.CanCancelEdit 屬性

定義

取得值,這個值表示集合檢視是否可以捨棄暫止的變更,並還原已編輯物件的原始值。

public:
 property bool CanCancelEdit { bool get(); };
public bool CanCancelEdit { get; }
member this.CanCancelEdit : bool
Public ReadOnly Property CanCancelEdit As Boolean

屬性值

如果集合檢視可以捨棄暫止的變更,並還原已編輯物件的原始值,則為 true,否則為 false

範例

下列範例會取得 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()

備註

CanCancelEdit 如果 true 檢視支援目前編輯專案上的「暫止變更」概念,則為 。 例如,如果編輯的項目實作 IEditableObject,或檢視有項目狀態的相關信息,則集合檢視可能會傳回true,以便用來復原變更。 CanCancelEditfalse如果檢視無法還原物件上的變更,則為 。 在此情況下,呼叫 CancelEdit 會導致檢視結束編輯狀態,並提供邏輯來還原已編輯之對象的變更。

適用於