BindingSource.AddingNew イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BindingSource.AddingNew イベントの意味・解説 

BindingSource.AddingNew イベント

メモ : このイベントは、.NET Framework version 2.0新しく追加されたものです。

項目が基底リスト追加される前に発生します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Event AddingNew As
 AddingNewEventHandler
Dim instance As BindingSource
Dim handler As AddingNewEventHandler

AddHandler instance.AddingNew, handler
public event AddingNewEventHandler AddingNew
public:
event AddingNewEventHandler^ AddingNew {
    void add (AddingNewEventHandler^ value);
    void remove (AddingNewEventHandler^ value);
}
/** @event */
public void add_AddingNew (AddingNewEventHandler
 value)

/** @event */
public void remove_AddingNew (AddingNewEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
例外例外
例外種類条件

InvalidOperationException

NewObject の型と、リスト格納されている型が異なります

解説解説

AddingNew イベントは、List プロパティ表される基底リスト新しオブジェクト追加される前に発生します。このイベントは、AddNew メソッド呼び出された後、新しい項目が作成され基底リスト追加される前に発生します。このイベント処理することにより、BindingSource からクラス派生せずに、項目を作成および挿入するためのカスタム動作プログラム上で定義できます。これは、イベント ハンドラで System.ComponentModel.AddingNewEventArgs パラメータNewObject プロパティ新しい項目に設定することによって実行できますAddingNew イベント作成され新しオブジェクトは、リスト格納されている型と同じ型であることが必要です。型が異な場合例外発生します。DataView または DataTable にバインドされている場合は、新しい DataRowView をリスト追加できないため、NewObject プロパティ設定することはできません。

新しい項目のカスタム機能定義する方法詳細については、AddNew メソッドトピック参照してくださいイベント処理詳細については、「イベント利用」を参照してください

使用例使用例

BindingSource コンポーネント使用してリストを DataGridView コントロールバインドするコード例次に示します新しい項目は、AddingNewイベント ハンドラによってリスト追加されます。次のコード例は、「方法 : Windows フォーム BindingSource を使用した項目の追加カスタマイズする」で示されている例の一部です。

Public Sub New()

    ' Set up the form.
    Me.Size = New Size(800, 800)
    AddHandler Me.Load, AddressOf
 Form1_Load
    Me.Controls.Add(status)

    ' Set up the DataGridView control.
    Me.customersDataGridView.Dock = DockStyle.Fill
    Me.Controls.Add(customersDataGridView)

End Sub
public Form1()
{
    // Set up the form.
    this.Size = new Size(800, 800);
    this.Load += new EventHandler(Form1_Load);
    this.Controls.Add(status);

    // Set up the DataGridView control.
    this.customersDataGridView.Dock = DockStyle.Fill;
    this.Controls.Add(customersDataGridView);

    // Attach an event handler for the AddingNew event.
    this.customersBindingSource.AddingNew += 
        new AddingNewEventHandler(customersBindingSource_AddingNew);

    // Attach an event handler for the ListChanged event.
    this.customersBindingSource.ListChanged += 
        new ListChangedEventHandler(customersBindingSource_ListChanged);
}
public:
    
    MainForm()
    {
        customersBindingSource = gcnew BindingSource;
        customersDataGridView = gcnew DataGridView;
        status = gcnew StatusBar;

        // Set up the form.
        this->Size = System::Drawing::Size(600, 400);
        this->Text = "BindingSource.AddingNew sample";
        this->Load += 
            gcnew EventHandler(this, &MainForm::OnMainFormLoad);
        this->Controls->Add(status);
          
        // Set up the DataGridView control.
        this->customersDataGridView->Dock = DockStyle::Fill;
        this->Controls->Add(this->customersDataGridView);
          
        // Attach an event handler for the AddingNew event.
        this->customersBindingSource->AddingNew += 
            gcnew AddingNewEventHandler(this, 
            &MainForm::OnCustomersBindingSourceAddingNew);
          
        // Attach an event handler for the ListChanged event.
        this->customersBindingSource->ListChanged += 
            gcnew ListChangedEventHandler(this, 
            &MainForm::OnCustomersBindingSourceListChanged);
    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingSource クラス
BindingSource メンバ
System.Windows.Forms 名前空間
AddNew
OnAddingNew
System.ComponentModel.AddingNewEventArgs


このページでは「.NET Framework クラス ライブラリ リファレンス」からBindingSource.AddingNew イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBindingSource.AddingNew イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBindingSource.AddingNew イベント を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「BindingSource.AddingNew イベント」の関連用語

BindingSource.AddingNew イベントのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BindingSource.AddingNew イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS