AddingNewEventArgs 類別


提供 AddingNew 事件的資料。Provides data for the AddingNew event.

public ref class AddingNewEventArgs : EventArgs
public class AddingNewEventArgs : EventArgs
type AddingNewEventArgs = class
    inherit EventArgs
Public Class AddingNewEventArgs
Inherits EventArgs


下列程式碼範例示範如何使用 AddingNewEventArgs 類別來處理 BindingSource.AddingNew 事件。The following code example demonstrates how to use the AddingNewEventArgs class to handle the BindingSource.AddingNew event. 這個程式碼範例是 how to:使用 Windows Forms BindingSource 自訂加入專案中提供之較大範例的一部分。This code example is part of a larger example provided in How to: Customize Item Addition with the Windows Forms BindingSource.

// This event handler provides custom item-creation behavior.
void OnCustomersBindingSourceAddingNew(Object^ sender, 
    AddingNewEventArgs^ e)
    e->NewObject = DemoCustomer::CreateNewCustomer();
// This event handler provides custom item-creation behavior.
void customersBindingSource_AddingNew(
    object sender, 
    AddingNewEventArgs e)
    e.NewObject = DemoCustomer.CreateNewCustomer();
' This event handler provides custom item-creation behavior.
 Private Sub customersBindingSource_AddingNew( _
 ByVal sender As Object, _
 ByVal e As AddingNewEventArgs) _
 Handles customersBindingSource.AddingNew

     e.NewObject = DemoCustomer.CreateNewCustomer()

 End Sub


AddingNewEventArgs 類別提供 BindingSource.AddingNew 事件的資料,表示專案即將新增至集合。The AddingNewEventArgs class provides data for the BindingSource.AddingNew event, which signals that an item is about to be added to a collection. 事件可讓程式設計人員在事件處理常式 AddingNewEventHandler中,藉由將 NewObject 屬性設定為這個新專案,提供新物件的選項。The event gives the programmer, within the event handler AddingNewEventHandler, the option of supplying the new object by setting the NewObject property to this new item. 如果未設定此屬性,則集合通常會使用適當類型的無參數函式來建立新的專案。If this property is not set, the collection will typically use the parameterless constructor of the appropriate type to construct a new item. 不論是哪一種情況,都會將新的專案新增至集合。In either case, the new item will be added to the collection.

如果集合也會執行 ICancelAddNew 介面,則會 provisionally 加入專案,等待後續的認可或復原。If the collection also implements the ICancelAddNew interface, the item will be provisionally added, waiting a subsequent commit or rollback.

這個事件通常用於資料系結案例中,例如 System.Windows.Forms.BindingSourceSystem.ComponentModel.BindingList<T>等類別中。This event is commonly used in data-binding scenarios, within classes such as System.Windows.Forms.BindingSource and System.ComponentModel.BindingList<T>.

如需如何處理事件的詳細資訊,請參閱處理和引發事件For more information about how to handle events, see Handling and Raising Events.



不使用參數來初始化 AddingNewEventArgs 類別的新執行個體。Initializes a new instance of the AddingNewEventArgs class using no parameters.


使用指定的物件當做新項目,初始化 AddingNewEventArgs 類別的新執行個體。Initializes a new instance of the AddingNewEventArgs class using the specified object as the new item.



取得或設定要加入至繫結清單的物件。Gets or sets the object to be added to the binding list.



判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)