共用方式為


AddingNewEventArgs.NewObject 屬性

定義

取得或設定要加入至繫結清單的物件。

public:
 property System::Object ^ NewObject { System::Object ^ get(); void set(System::Object ^ value); };
public object NewObject { get; set; }
public object? NewObject { get; set; }
member this.NewObject : obj with get, set
Public Property NewObject As Object

屬性值

Object,當做要加入至關聯集合的新項目。

範例

下列程式代碼範例示範如何使用 AddingNewEventArgs 類別來處理 BindingSource.AddingNew 事件。 此程式代碼範例是 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

備註

NewObject如果 屬性設定為 null,則表示集合是採取標準動作,這通常需要使用其無參數建構函式建立適當類型的物件,然後將它新增至集合。

適用於

另請參閱