Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / key not found – Parameter name: key

key not found – Parameter name: key

New Discussion
Patrick
Patrick asked on Nov 17, 2016 1:20 PM

When I run the following code (VB.Net) I get the error message:  key not found Parameter name: key  when I try to attach the [Grid] to a [Tab]

 Is this a "key" property with the [Grid] or with the [Tab] that it resides on?

I'm dynamically adding the [Tab] and the [Grid] at runtime.

If I insert a [Grid] on a [Tab] at design and run similar code to load my data, I do not get this error message.

What have I missed?

 ==================================================================

Dim OptiSaveViewGroup As New clsGroups()

'……………………………….Dim osvgGroupDataSet As DataSet = OptiSaveViewGroup.GetOptiSaveViewData2(CInt(txtRunNumber.Text))

'————————————Dim Grid1 As UltraWinGrid.UltraGrid

Grid1 =

New UltraWinGrid.UltraGridWith Grid1

.DataSource = osvgGroupDataSet

.DisplayLayout.Appearance.BackColor = Color.White

.DisplayLayout.Appearance.BorderColor = Color.DarkGray

.DisplayLayout.Appearance.Key =

"Tab2"

.DisplayLayout.Bands(0).HeaderVisible =

True

.DisplayLayout.Bands(0).Header.Caption =

"OptiSave Report"

.DisplayLayout.Bands(0).AutoPreviewEnabled =

True

.DisplayLayout.AutoFitStyle = UltraWinGrid.AutoFitStyle.ResizeAllColumns

.DisplayLayout.ScrollBounds = UltraWinGrid.ScrollBounds.ScrollToFill

.DisplayLayout.ScrollStyle = UltraWinGrid.ScrollStyle.Immediate

.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True

.Dock = DockStyle.Fill

End With

UltraTabControl1.Tabs(ActiveTabName).TabPage.Controls.Add(Grid1)

Grid1.Refresh()

 

Thanks ahead of time.

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Jan 10, 2008 2:17 PM

    That error usually means you are trying to refer to an object in a collection by a key that does not exist in the collection. My guess is that your UltraTabControl does not have a tab whose key is ActiveTabName.  

    • 0
      Patrick
      Patrick answered on Jan 10, 2008 3:15 PM

      Your right Mike, I actually figured that out after I sent the blog to ya.

      Thanks for your help.

      PR

      PS: Love your controls!

    • 0
      Rahul
      Rahul answered on May 24, 2010 12:23 PM

      Hi Mike,

      I saw the above thread. I am also getting the same error.  Please, find the error trace below. Need your help in this.

      Error:
      Exception Caught: Key not found
      Parameter name: key

      at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key)
      at Infragistics.Win.UltraWinToolbars.ToolsCollectionBase.get_Item(String key)
      at Allscripts.TouchWorks.Common.PanelOrderViewer.UpdateButtonsState()
      at Allscripts.TouchWorks.Common.PanelOrderViewer.OnLoad(EventArgs e)
      at System.Windows.Forms.UserControl.OnCreateControl()
      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
      at System.Windows.Forms.Control.CreateControl()
      at System.Windows.Forms.Control.ControlCollection.Add(Control value)
      at Allscripts.TouchWorks.Common.Viewer.SetDisplayItem(BusinessObject oItem)
      at Allscripts.TouchWorks.Common.TWWorkspace.ShowViewer(Boolean bNewWindow)
      at Allscripts.TouchWorks.Workspace.ChartViewer.ChartViewerControl.m_ToolbarsManager_ToolClick(Object sender, ToolClickEventArgs e)
      at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.OnToolClick(ToolClickEventArgs e)
      at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.FireEvent(ToolbarEventIds id, EventArgs e)
      at Infragistics.Win.UltraWinToolbars.ToolBase.OnToolClick()
      at Infragistics.Win.UltraWinToolbars.ToolMenuItem.OnClick()
      at Infragistics.Win.UltraWinToolbars.PopupMenuItemUIElement.DoClickProcessing(MouseEventArgs e)
      at Infragistics.Win.UltraWinToolbars.PopupMenuItemUIElement.OnMouseUp(MouseEventArgs e)
      at Infragistics.Win.UIElement.OnMouseUp(MouseEventArgs e)
      at Infragistics.Win.TextUIElementBase.OnMouseUp(MouseEventArgs e)
      at Infragistics.Win.ControlUIElementBase.ProcessMouseUpHelper(Object sender, MouseEventArgs e)
      at Infragistics.Win.ControlUIElementBase.ProcessMouseUp(Object sender, MouseEventArgs e)
      at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
      at Infragistics.Win.UltraControlBase.OnMouseUp(MouseEventArgs e)
      at Infragistics.Win.UltraWinToolbars.PopupControlBase.OnMouseUp(MouseEventArgs e)
      at System.Windows.Forms.Control.WmMouseUp(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)

      Assembly Name: Infragistics.Shared.KeyedSubObjectsCollectionBase
      Assembly File: Infragistics2.Shared.v9.2.dll
      Assembly Version: 9.2.20092.2042
      Assembly Path: C:\WINDOWS\assembly\GAC_MSIL\Infragistics2.Shared.v9.2\9.2.20092.2042__7dd5c3163f2cd0cb\Infragistics2.Shared.v9.2.dll
      .NET Version: v2.0.50727

      • 0
        Mike Saltzman
        Mike Saltzman answered on May 24, 2010 9:57 PM

        Hi,

        This error message indicates that something in your code is trying to reference an object in a collection using a key that does not exist.

        From the Call Stack, it appears that you are handling the ToolClick event of a tool in UltraToolbarsManager and which calls intothis method.

        Allscripts.TouchWorks.Workspace.ChartViewer.ChartViewerControl.m_ToolbarsManager_ToolClick(Object
        sender, ToolClickEventArgs e)

        And this code is ultimately trying to reference a tool with a non-existant key when it gets to this method:

        at Allscripts.TouchWorks.Common.PanelOrderViewer.UpdateButtonsState()

      • 0
        Rahul
        Rahul answered on May 25, 2010 7:29 AM

        Hi Mike,

        Thanks for the quick response. So, do I need to check for the existence for the following:

        this.popupPrintFax.Tools["btnPrintReq"].SharedProps.Enabled = false;
        this.popupPrintFax.Tools["btnFaxReq"].SharedProps.Enabled = false;
        this.popupPrintFax.Tools["btnPrintRes"].SharedProps.Enabled = false;
        this.popupPrintFax.Tools["btnFaxRes"].SharedProps.Enabled = false; 

        Could you give me a sample Psuedocode for this.

      • 0
        Mike Saltzman
        Mike Saltzman answered on May 25, 2010 3:02 PM

        Nothing to it:

        
        

        if (this.popupPrintFax.Tools.Exists("btnPrintReq"))
                        this.popupPrintFax.Tools["btnPrintReq"].SharedProps.Enabled = false;

      • 0
        Ben Cannaught
        Ben Cannaught answered on Nov 17, 2016 1:20 PM

        Hi Mike,

        I am facing the same problem refer below trace.

        Error is

        Key Not Found

        Parameter Name:key

        at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key)
        at Infragistics.Win.UltraWinGrid.ColumnsCollection.get_Item(String key)
        at Project_Name.frmMain.ugVisitIDList_InitializeLayout(Object sender, InitializeLayoutEventArgs e)
        at Infragistics.Win.UltraWinGrid.UltraGrid.OnInitializeLayout(InitializeLayoutEventArgs e)
        at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e)
        at Infragistics.Win.UltraWinGrid.UltraGridLayout.ApplyLoadedBands()
        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 Project_Name.frmMain.btnGenerateList_Click(Object sender, EventArgs e)

    • 0
      Lava Kumar
      Lava Kumar answered on Jan 6, 2016 7:33 AM

      Hi Mike ,

                   i have similar issue ,pls help me in this regard.

      Client Handler ID:5968c4ff-38ce-4d7c-9c9b-69ea98eacb6b
      —————————————————————————————————
      Exception Message:
      Key not found: 'TYPE_KEY'
      Parameter name: key
      —————————————————————————————————
      Stack Trace:
      at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key)
      at Infragistics.Win.UltraWinGrid.ColumnsCollection.get_Item(String key)
      at Infragistics.Win.UltraWinGrid.CellsCollection.GetItem(String key)
      at Infragistics.Win.UltraWinGrid.CellsCollection.get_Item(String key)
      at SearchEditEntityView.SelectedRow()
      at SearchEditEntityView.SearchGrid_DoubleClickRow(Object sender, DoubleClickRowEventArgs e)
      at Infragistics.Win.UltraWinGrid.UltraGrid.OnDoubleClickRow(DoubleClickRowEventArgs e)
      at Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e)
      at Infragistics.Win.UltraWinGrid.GridCellEmbeddableEditorOwnerInfoBase.OnEditorDoubleClick(EmbeddableUIElementBase embeddableElem, EmbeddableClickEventArgs e)
      at Infragistics.Win.EmbeddableUIElementBase.RaiseDoubleClickEvent(UIElement sender, Boolean isButton)
      at Infragistics.Win.EmbeddableUIElementBase.OnDoubleClick(Boolean adjustableArea)
      at Infragistics.Win.UIElement.OnDoubleClick(Boolean adjustableArea)
      at Infragistics.Win.ControlUIElementBase.ProcessDoubleClick(Object sender, EventArgs e)
      at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
      at Infragistics.Win.UltraControlBase.OnDoubleClick(EventArgs e)
      at System.Windows.Forms.Control.WmMouseUp(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)

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jan 6, 2016 2:29 PM

        Hi Lava,

        This exception indicates that you are trying to reference a Cell in the grid using a Key of a column that does not exist. You should probably check out that code and see why you are doing that. Maybe it's an unbound column and you are trying to access the cell before that column was added? If so, then a simple solution would be to use the Exists method to make sure the cell is there before you try to access it, just as I did in the sample code above.

      • 0
        Lava Kumar
        Lava Kumar answered on Jan 7, 2016 9:00 AM

        Thanks   Mike :)..I will look in to that ..

      • 0
        Lava Kumar
        Lava Kumar answered on Jan 12, 2016 11:08 AM

        Hi Mike ,

                      There is an another issue , where  when I am tabbing it is giving me a "Object reference not set to an instance of an object  exception" ..

        below is the exception details , when I debugged I got to know that  "obj.FocusControl  " is null ,pls guide me in this  on setting the Focus Control  property with some thing from the code.

        Exception Message:

        Object reference not set to an instance of an object.

        —————————————————————————————————

        Stack Trace:

        at views..SearchGrid_KeyDown(Object sender, KeyEventArgs e)

        at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)

        at Infragistics.Win.UltraControlBase.OnKeyDown(KeyEventArgs e)

        at Infragistics.Win.UltraWinGrid.UltraGridBase.EditorContainerControlOnKeyDown(KeyEventArgs e)

        at Infragistics.Win.UltraWinGrid.UltraGridBase.OnKeyDownForwarded(KeyEventArgs e)

        at Infragistics.Win.UltraWinGrid.UltraGridLayout.OnEditorKeyDown(Object sender, KeyEventArgs e)

        at Infragistics.Win.EmbeddableEditorBase.RaiseKeyDownEvent(KeyEventArgs e)

        at Infragistics.Win.EmbeddableTextBox.OnKeyDown(KeyEventArgs e)

        at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.ProcessKeyMessage(Message& msg)

        at System.Windows.Forms.Control.WmKeyChar(Message& m)

        at System.Windows.Forms.Control.WndProc(Message& m)

        at System.Windows.Forms.TextBoxBase.WndProc(Message& m)

        at System.Windows.Forms.TextBox.WndProc(Message& m)

        at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.WndProcInternal(Message& m)

        at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.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)

      • 0
        Mike Saltzman
        Mike Saltzman answered on Jan 12, 2016 2:33 PM

        Hi Lava,

        I'm not sure how I can help you with this. According to the call stack, the exception is occurring in the KeyDown event handler for your grid. So it's your code that's raising the exception because you are trying to reference a property of an object that is null. You need to find out why that object is null or add a null check so that code does not get called when there's no object to call the method on.

      • 0
        J. Griggs
        J. Griggs answered on Mar 1, 2016 3:42 PM

        I'm getting something similar, can you decipher?

         

        System.ArgumentException: Key not found Parameter name: key    at Infragistics.Shared.KeyedSubObjectsCollectionBase.GetItem(String key)    at Infragistics.Win.UltraWinGrid.ColumnsCollection.get_Item(String key)    at Infragistics.Win.UltraWinGrid.UltraGridBand.get_ScrollTipCol()    at Infragistics.Win.UltraWinGrid.UltraGridRow.GetScrollTip(Int32& lineCount)    at Infragistics.Win.UltraWinGrid.RowScrollRegion.ScrollRows(ScrollEventType scrollType, ScrollRowsContext& src)    at Infragistics.Win.UltraWinGrid.RowScrollRegion.OnScroll(ScrollBarInfo scrollBar, ScrollEventType scrollType, Boolean exitEditMode, Boolean invalidateRegion)    at Infragistics.Win.UltraWinGrid.ScrollRegionBase.OnScroll(Object sender, ScrollEventArgs e)    at Infragistics.Win.UltraWinScrollBar.ScrollBarInfo.OnScroll(ScrollEventArgs e)    at Infragistics.Win.UltraWinScrollBar.ScrollBarInfo.StartThumbDrag(Int32 offsetX, Int32 offsetY)    at Infragistics.Win.UltraWinScrollBar.ScrollThumbUIElement.OnMouseDown(MouseEventArgs e, Boolean adjustableArea, UIElement& captureMouseForElement)    at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e)    at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e)    at System.Windows.Forms.MouseEventHandler.Invoke(Object sender, MouseEventArgs e)    at System.Windows.Forms.Control.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)

      • 0
        Mike Saltzman
        Mike Saltzman answered on Mar 2, 2016 2:28 PM

        According to this, the grid is trying to get the ScrollTipField column and the name you specified for the ScrollTipField does not exist in the band.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Patrick
Favorites
0
Replies
14
Created On
Nov 17, 2016
Last Post
9 years, 3 months ago

Suggested Discussions

Tags

Created by

Created on

Nov 17, 2016 1:20 PM

Last activity on

Feb 16, 2026 9:38 PM