I have a GridView that is bound to a binding list
BindingList<DataElementMap> DataElementMaps { get; set; }
mappingsGridView.DataSource = DataElementMaps;
I am adding a menu item to the Context Menu using the following
This works fine until I clear the data bound list. (i.e. DataElementMaps.Clear(); )
After a clear is executed the above code throws the following exception
System.ArgumentException occurred
Message=Cannot remove the specified item because it was not found in the specified Collection.
Source=mscorlib
StackTrace:
at System.Collections.CollectionBase.System.Collections.IList.Remove(Object value)
at Telerik.WinControls.RadElementCollection.CheckElementAlreadyAdded(RadElement element)
at Telerik.WinControls.RadElementCollection.OnInsert(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Insert(Int32 index, Object value)
at Telerik.WinControls.RadItemOwnerCollection.OnInsertComplete(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at Telerik.WinControls.RadItemCollection.AddRange(RadItem[] value)
BindingList<DataElementMap> DataElementMaps { get; set; }
mappingsGridView.DataSource = DataElementMaps;
I am adding a menu item to the Context Menu using the following
private
void
mappingsGridView_ContextMenuOpening(
object
sender, ContextMenuOpeningEventArgs e)
{
if
(!e.ContextMenu.Items.Contains(_ceateTransformationMenuItem))
{
e.ContextMenu.Items.AddRange(_ceateTransformationMenuItem);
}
}
This works fine until I clear the data bound list. (i.e. DataElementMaps.Clear(); )
After a clear is executed the above code throws the following exception
System.ArgumentException occurred
Message=Cannot remove the specified item because it was not found in the specified Collection.
Source=mscorlib
StackTrace:
at System.Collections.CollectionBase.System.Collections.IList.Remove(Object value)
at Telerik.WinControls.RadElementCollection.CheckElementAlreadyAdded(RadElement element)
at Telerik.WinControls.RadElementCollection.OnInsert(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Insert(Int32 index, Object value)
at Telerik.WinControls.RadItemOwnerCollection.OnInsertComplete(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at Telerik.WinControls.RadItemCollection.AddRange(RadItem[] value)