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集合视图并导致集合视图退出编辑状态。 CanCancelEdit如果是trueCancelEdit则还会还原已编辑对象的原始值。

适用于