Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
450
ArgumentException thrown when I switch data source
posted

I am getting an ArgumentException throw when I switch datasources. I am using a BindingList on an internal business object and when I try to switch the initial binding list for an alternative instance of the same class I get an ArgumentException ("Key Already exists").

I have tried resetting the DisplayLayout viz,

    grid.DataSource = null;

    grid.DisplayLayout.Reset();

    grid.DataSource = newBindingList;

But I still get the exception. 

The stack trace from the exception is:

.  at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key, IKeyedSubObject ignoreObject)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key)
   at Infragistics.Shared.KeyedSubObjectsCollectionBase.InternalAdd(IKeyedSubObject obj)
   at Infragistics.Win.UltraWinGrid.ColumnsCollection.InternalAdd(UltraGridColumn column)
   at Infragistics.Win.UltraWinGrid.UltraGridBand.InitColumns(UltraGridBand[ oldBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[ oldBands)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()
   at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value)
   at AspenTech.AspenCxs.InfragisticsControls.CxsExplorer.SynchronizeDetailsView(CxsNodeCollection newNodes) in C:\Rnd\AspenCXS\dev\Source\AspenTech.AspenCxs.InfragisticsControls\CxsExplorer.cs:line 174
   at AspenTech.AspenCxs.InfragisticsControls.CxsExplorer._treeNavigator_AfterSelect(Object sender, SelectEventArgs e) in C:\Rnd\AspenCXS\dev\Source\AspenTech.AspenCxs.InfragisticsControls\CxsExplorer.cs:line 146
   at Infragistics.Win.UltraWinTree.UltraTree.OnAfterSelect(SelectEventArgs e)
   at Infragistics.Win.UltraWinTree.UltraTree.FireEvent(TreeEventIds id, EventArgs e)
   at Infragistics.Win.UltraWinTree.UltraTree.SelectNewSelection(SelectedNodesCollection selected, Boolean isRangeSelect)
   at Infragistics.Win.UltraWinTree.UltraTree.SelectNewSelection(SelectedNodesCollection selected)
   at Infragistics.Win.UltraWinTree.UltraTree.InternalSelectItem(ISelectableItem item, Boolean clearExistingSelection, Boolean select)
   at Infragistics.Win.UltraWinTree.UltraTree.Infragistics.Win.ISelectionManager.SelectItem(ISelectableItem item, Boolean clearExistingSelection)
   at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo, Boolean forceDrag)
   at Infragistics.Win.SelectionStrategySingle.OnMouseDown(ISelectableItem item, MouseMessageInfo& msginfo)
   at Infragistics.Win.SelectionStrategySingle.OnMouseMessage(ISelectableItem item, MouseMessageInfo& msginfo)
   at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e)
   at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e)
   at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
   at Infragistics.Win.UltraControlBase.OnMouseDown(MouseEventArgs e)
   at Infragistics.Win.UltraWinTree.UltraTree.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)