Hi All,
Honestly I couldn't figure out where to ask this question so I am trying my chance here.
I am getting System.IndexOutOfRangeException in Application.Run(new frmMain); line. Since this much information didn't make sense to me having this exception in the main method and I couldn't succeed to reproduce the error, I checked stack trace for further information on the error.
here it is;
-----------------------------------------------------------------------------------------------------------------------------------------------
System.IndexOutOfRangeException was unhandled
Message="Index -1 does not have a value."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.CurrencyManager.get_Current()
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowEnter(DataGridViewCellEventArgs e)
at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean validationFailureOccurred)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.OnCellMouseDown(HitTestInfo hti, Boolean isShiftDown, Boolean isControlDown)
at System.Windows.Forms.DataGridView.OnCellMouseDown(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.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.DataGridView.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MyApplication.Program.Main() in C:\Dokumente und Einstellungen\xxxx\Eigene Dateien\Visual Studio 2005\Projects\MyApplication\MyApplication\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
-----------------------------------------------------------------------------------------------------------------------------------------------
From stack trace information I have the impression of that datagridview control on the child form of mdiform (frmMain) causing this. Here is the situation in my Application.
I have frmMain as mdicontainer and frmPart as mdichild. in frmPart I have a combobox that feeds first datagridview and a second datagridview control which acts in a master-detail relation with the first one.
Also in the second dgv I have 3 checkboxcolumns where I handled the cellcontentclick event to get checkboxes on the same row act like a group of radio buttons. Some values in the first dgv are getting updated according to selections in second datagridview.
I hope I didn't messed up the question text because I already messed up my application. Another messup is the last thing I need now
Can anyone tell me what may be causing getting this exception or error in the main method of the program
Regards
Flatwhite