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.

  • 如果尚未認可暫止的加法,方法將會回復。CancelNewThe CancelNew method will roll back the pending addition if it has not already been committed.

注意

在某些情況下, 例如 Windows Forms 複雜的資料系結, 集合可能CancelNewEndNew接收或呼叫新加入專案以外的專案。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.

適用於

另請參閱