我的应用程序中有一个BindingList
,我希望能够使用AddingNew
事件来确定列表中的项目是否包含即将添加的信息。如果是这样,应该中止添加该项目。如何防止将项目添加到AddingNew事件中的BindingList?
基本上,我在找什么,就像e.Cancel = true;
。但它不存在。那么,我们如何防止添加项目之前添加项目?
private void AudioStreams_AddingNew(object sender, AddingNewEventArgs e)
{
byte[] tempStream = (byte[])e.NewObject;
if (tempStream != null)
{
foreach (var item in AudioStreams)
{
if (item.AudioStream == tempStream)
{
e.Cancel = true; // Can't do this but need a way to do it.
}
}
}
}
是其绑定到一个DataGridView或其他一些控制? – Larry