ICancelAddNew 接口

定义

在向集合添加新项时添加事务性功能。Adds transactional capability when adding a new item to a collection.

public interface class ICancelAddNew
public interface ICancelAddNew
type ICancelAddNew = interface
Public Interface ICancelAddNew
派生

注解

ICancelAddNew接口允许集合以可扩展的方式添加新项。The ICancelAddNew interface enables a collection to add a new item in an extensible way. 然后, 可以提交或回滚新项。The new item subsequently can be committed or rolled back. 集合AddNew的方法用于暂时添加项, 后者随后将通过以下操作进行处理:The AddNew method of the collection is used to tentatively add the item, which is subsequently transacted through the following operations:

  • EndNew方法将显式提交挂起的添加。The EndNew method will explicitly commit the pending addition.

  • 执行其他集合操作 (如插入、删除或移动) 将隐式提交挂起的添加操作。Performing another collection operation, such as an insertion, removal, or move will implicitly commit the pending addition.

  • 如果CancelNew尚未提交挂起的添加方法, 该方法将回滚该方法。The CancelNew method will roll back the pending addition if it has not already been committed.

备注

在某些情况下 (例如 Windows 窗体复杂数据绑定), 集合可能会CancelNew接收EndNew或调用新添加项之外的项。In some scenarios, such as Windows Forms complex data binding, the collection may receive CancelNew or EndNew calls for items other than the newly added item. (每个项通常是数据视图中的一行。)忽略这些调用;仅当指定了该项的索引时才取消或提交新项。(Each item is typically a row in a data view.) Ignore these calls; cancel or commit the new item only when that item's index is specified.

有两种模型允许将项事务性添加到数据绑定集合:There are two models that allow transactional addition of an item to a data-bound collection:

方法

CancelNew(Int32)

丢弃集合中挂起的新项。Discards a pending new item from the collection.

EndNew(Int32)

向集合提交挂起的新项。Commits a pending new item to the collection.

适用于

另请参阅