469,934 Members | 2,756 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

DataGridView: Index -1 does not have a value


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()
Sep 28 '05 #1
0 2740

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Riley | last post: by
3 posts views Thread by Johnny E. Jensen | last post: by
reply views Thread by Scotty | last post: by
2 posts views Thread by Scotty | last post: by
4 posts views Thread by =?Utf-8?B?anAybXNmdA==?= | last post: by
6 posts views Thread by Miro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.