BindingList.AddNew メソッド
アセンブリ: System (system.dll 内)

Dim instance As BindingList(Of T) Dim returnValue As T returnValue = instance.AddNew
リストに追加する項目。


AddNew メソッドは、Items プロパティで表されるコレクションに新しい項目を追加します。新しい項目を追加するには、次のロジックを使用します。
-
このイベントをプログラム上で処理することにより、新しいカスタム項目を作成できます。これは、イベント ハンドラで AddingNewEventArgs パラメータの NewObject プロパティを新しい項目に設定することによって実行できます。

AddNew メソッドを使用する方法を次のコード例に示します。詳細については、BindingList クラスの概要のトピックを参照してくださいBindingList。
' Add the new part unless the part number contains ' spaces. In that case cancel the add. Private Sub button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles button1.Click Dim newPart As Part = listOfParts.AddNew() If newPart.PartName.Contains(" ") Then MessageBox.Show("Part names cannot contain spaces.") listOfParts.CancelNew(listOfParts.IndexOf(newPart)) Else textBox2.Text = randomNumber.Next(9999).ToString() textBox1.Text = "Enter part name" End If End Sub
// Add the new part unless the part number contains // spaces. In that case cancel the add. private void button1_Click(object sender, EventArgs e) { Part newPart = listOfParts.AddNew(); if (newPart.PartName.Contains(" ")) { MessageBox.Show("Part names cannot contain spaces."); listOfParts.CancelNew(listOfParts.IndexOf(newPart)); } else { textBox2.Text = randomNumber.Next(9999).ToString(); textBox1.Text = "Enter part name"; } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


BindingList ジェネリック クラス
BindingList メンバ
System.ComponentModel 名前空間
IBindingList.AddNew
Activator.CreateInstance
Items
AddingNew
AllowNew
EndNew
CancelNew
RemoveItem
ListChanged
Weblioに収録されているすべての辞書からBindingList.AddNew メソッドを検索する場合は、下記のリンクをクリックしてください。

- BindingList.AddNew メソッドのページへのリンク