StrataFrame Forum

Browse Dialog index was out of range error.

http://forum.strataframe.net/Topic23768.aspx

By Keith Gordijn - 7/8/2009

Hi Guys,



I had two maintenance forms with browsedialogs one for contacts and one for clients both of which have been working for some time. Recently I created a person table to replace a contact and client table. As part of this change I used the same dialog boxes but replaced the BusinessObjectType for the PersonBO and also the search fields for the person fields I want. Everything compiles fine.



However, now when I select the search action I get a dialogbox with:



Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index





My log file contains the following:

Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)

at System.ThrowHelper.ThrowArgumentOutOfRangeException()

at System.Collections.Generic.List`1.get_Item(Int32 index)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.SetGroupBoxDimensions()

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow..ctor(BrowseDialog browse, Boolean PopulateOnShow)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow, IWin32Window ResultsWindowOwner)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog()

at FitTrack.ContactMaintenance.SearchForRecord() in C:\Projects\FitTrack\FitTrack\FitTrack\Dialogs\Maintenance\ContactMaintenance\ContactMaintenance.cs:line 307

at FitTrack.ContactMaintenance.lnkFindContact_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) in C:\Projects\FitTrack\FitTrack\FitTrack\Dialogs\Maintenance\ContactMaintenance\ContactMaintenance.cs:line 105

at System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e)

at System.Windows.Forms.LinkLabel.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.Label.WndProc(Message& m)

at System.Windows.Forms.LinkLabel.WndProc(Message& msg)

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)




I have tried everything I could find on the forum related to this type of problem, ie. registry paths, recreating the searchfields, even recreating the browsedialogs and have had no luck.



Other forms that I have not changed still work ok and my eyes are hanging out trying to find what is wrong. One thing I have found that is different is the non working browsedialogs have the line searchFieldItem2.FieldType = System.Data.DbType.AnsiString; in for example the ContactBrowseDialog.Designer.cs while working browsedialogs do not have this in their designer.cs files..



Anyway I am rapidly tearing what hair I have left out so any help would be great.



TIA,

Keith
By Trent L. Taylor - 7/8/2009

It looks like you do not have any search fields showing up within the group box which is most likely because you have a registry key that is saving off the search fields, etc. that the user has selected, but since you no longer have those search fields as part of the browse dialog, then no search fields are appearing within search area. The bottom control is used for spacing, so that is causing the error. Under normal circumstances this wouldn't happen, and I just plugged the hole to prevent the error, but you need to either remove the key within the registry or change the registry key on the control so that it can reload your "default" search fields.
By Keith Gordijn - 7/8/2009

Yep, that was it!



Looked in the registry and the old field names were in there. I had removed the registry setting from my maintenance form, still got the error so put it back. All of which means I probably would never have gone further and actually looked into the registry. Anyway removing the registry entry did the trick.



Thanks Trent.