Hi I am trying to add Tool to UltraToolbarsManager control at run time. the code is given below.
private void AddContextMenuItem() { if (ultraToolbarsManager1.Tools.Count > 0) this.ultraToolbarsManager1.Tools.Clear(); this.ultraToolbarsManager1.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool1, stateButtonTool1, buttonTool2, buttonTool3, buttonTool4, buttonTool5, buttonTool6, popupMenuTool1, buttonTool17, buttonTool18, buttonTool19, buttonTool20, buttonTool22, buttonTool24}); }
But i am getting error .Exception Caught: Key already existsParameter name: Key
The the trace is given below
at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key) at Infragistics.Win.UltraWinToolbars.ToolsCollectionBase.ValidateKeyIsntUsed(String key) at Infragistics.Win.UltraWinToolbars.ToolsCollectionBase.AddHelper(ToolBase tool, Boolean honorReadOnlyStatus, Int32 insertAtIndex) at Infragistics.Win.UltraWinToolbars.ToolsCollectionBase.Add(ToolBase tool) at Infragistics.Win.UltraWinToolbars.RootToolsCollection.Add(ToolBase tool) at Infragistics.Win.UltraWinToolbars.ToolsCollectionBase.AddRange(ToolBase[] tools) at Infragistics.Win.UltraWinToolbars.RootToolsCollection.AddRange(ToolBase[] tools) at Allscripts.TouchWorks.Common.PanelAddNewQuickSet.AddContextMenuItem() at Allscripts.TouchWorks.Common.PanelAddNewQuickSet.treeQuickSet_AfterSelect(Object sender, SelectEventArgs e) 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, Boolean invalidate) at Infragistics.Win.UltraWinTree.UltraTree.InternalSelectItem(ISelectableItem item, Boolean clearExistingSelection, Boolean select, Boolean invalidate) 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 Allscripts.TouchWorks.Common.TWTree.OnMouseDown(MouseEventArgs e) in D:\Works.NET\Allscripts.TouchWorks.CommonControls\treecontrol\TWTree.cs:line 296 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)
Thanks
krishna
Look at the code which creates each of those tools added to the Tools collection. Do they all have unique keys?