troubleshooting Question

DataGridView Delete Problem

Avatar of robtrue
robtrueFlag for United States of America asked on
Visual Basic.NETVisual C++.NETMicrosoft Development
2 Comments1 Solution933 ViewsLast Modified:
I have a Datagridview control in a winForm application bound to a data adapter that references an Access 2007 table. The properties AlowUserToAddRows, AllowUserToDeleteRows, and MultiSelect are all set to True.  Everything works find except the following case:

If the user selects all the rows in the datagridview including the “*” row at the bottom of the datagridview and press the Delete key.  All the displayed records disappear and the “*” row is highlighted (selected).  Next the user clicks in the first column (or any column) of the “*” row and attempts to enter new data.  Upon depressing a keyboard key the message below appears.

    The following exception occurred in the DataGridView:

    System.IndexOutOfRangeException: Index 0 does not have a value. at
    System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at
    System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(int32 rowIndex)

    To replace this default dialog please handle the DataError event.

Note: Selecting all the rows except the “*” row at the bottom of the DataGridView works as expected.  Also, selecting only the “*” row while there are other rows in the DatGridView, and pressing the delete key and entering new data works just fine.  The error happens when all rows included the “*” rows are deleted and new data is entered.

Any ideas on how to fix this problem?
ASKER CERTIFIED SOLUTION
rayraymp

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros