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

範例

下列程式碼範例示範如何使用AddingNewEventArgs類別來BindingSource.AddingNew處理事件。The following code example demonstrates how to use the AddingNewEventArgs class to handle the BindingSource.AddingNew event. 這個程式碼範例是如何:使用 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

備註

類別會提供BindingSource.AddingNew事件的資料, 表示專案即將新增至集合。 AddingNewEventArgsThe 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()

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

AddingNewEventArgs(Object)

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

屬性

NewObject

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

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

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

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

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

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱