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



CancelNew メソッドを使用する方法を次のコード例に示します。詳細については、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 名前空間
System.ComponentModel.ICancelAddNew
AddNew
EndNew
IndexOf
- BindingList.CancelNew メソッドのページへのリンク