By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

DataGridView: Index -1 does not have a value

P: n/a

I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List
of a custom class0: lstMyPersonnes = New List(Of clsPersonne).

When I add a new clsPersonne to lstMyPersonnes, and rebind the
lstMyPersonnes to my DataGridView.dataSource, it shows the new record in
the DataGridView as it should be.

But when I click on a cell of that row, I suddenly got this error: "Index -1
does not have a value"...

Does anybody has any idea how to get around this problem?

Thanks a lot in advance,


PS: I'm using the RC of Visual Team Suite.

The whole exception:

System.IndexOutOfRangeException was unhandled
Message="Index -1 does not have a value."
at System.Windows.Forms.CurrencyManager.get_Item(Int3 2 index)
at System.Windows.Forms.CurrencyManager.get_Current()
System.Windows.Forms.DataGridView.DataGridViewData Connection.OnRowEnter(Data
GridViewCellEventArgs e)
at System.Windows.Forms.DataGridView.OnRowEnter(DataG ridViewCell&
dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean
canCreateNewRow, Boolean validationFailureOccurred)
at System.Windows.Forms.DataGridView.SetCurrentCellAd dressCore(Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean
validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.OnCellMouseDown( HitTestInfo hti,
Boolean isShiftDown, Boolean isControlDown)
System.Windows.Forms.DataGridView.OnCellMouseDown( DataGridViewCellMouseEvent
Args e)
at System.Windows.Forms.DataGridView.OnMouseDown(Mous eEventArgs 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)
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsaf
eNativeMethods.IMsoComponentManager.FPushMessageLo op(Int32 dwComponentID,
Int32 reason, Int32 pvLoopData)
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun(
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoAppl
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(St
ring[] commandLine)
at Ghost.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.