Problem when closing Form containing DataGridView
-
Hi I have a very strange problem. I am using Visual Studio 2005 and C# to develop a Windows application. My database is a MS Access 2003 database. On my Form I have a DataGridView that is bound to a table in the database. There are also a few DataGridViewComboBoxColumns that are bound to different lookup tables in the database. I specify the BindingSources for all of these using the designer. When I run the app the DataGridView is populated as expected. The DataGridViewComboBoxes also work fine and I can change the values. The database is also updated correctly. So everything seemed fine. Then I added a Button control to the form by dragging a Button control from the Toolbox onto the Form. Before I added any further code I ran the app again to check something. This time I encountered a problem. After I clicked the Close button in the Controlbox (Top right on the form) the DataGridView gets cleared of data row by row and when all the rows have been cleared the following message appears: "Index 0 does not have a value.". I just cannot see the relationship between just adding a Button to the form and this error message. I am stumped and any advice will be appreciated. Regards. Kobus
-
Hi I have a very strange problem. I am using Visual Studio 2005 and C# to develop a Windows application. My database is a MS Access 2003 database. On my Form I have a DataGridView that is bound to a table in the database. There are also a few DataGridViewComboBoxColumns that are bound to different lookup tables in the database. I specify the BindingSources for all of these using the designer. When I run the app the DataGridView is populated as expected. The DataGridViewComboBoxes also work fine and I can change the values. The database is also updated correctly. So everything seemed fine. Then I added a Button control to the form by dragging a Button control from the Toolbox onto the Form. Before I added any further code I ran the app again to check something. This time I encountered a problem. After I clicked the Close button in the Controlbox (Top right on the form) the DataGridView gets cleared of data row by row and when all the rows have been cleared the following message appears: "Index 0 does not have a value.". I just cannot see the relationship between just adding a Button to the form and this error message. I am stumped and any advice will be appreciated. Regards. Kobus
It seems pretty obvious that you're trying to delete one more row than the grid has. Try using the debugger - I know, that might seem too much like being a programmer, but after the first few times, you'll find the debugger to be pretty damn useful.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
It seems pretty obvious that you're trying to delete one more row than the grid has. Try using the debugger - I know, that might seem too much like being a programmer, but after the first few times, you'll find the debugger to be pretty damn useful.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001