HiI 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".
This exception is thrown even if I do not make any changes to the data that is bound to the DataGridView. So even when I run the app and immediately closes the app without doing anything to the data, the exception is thrown.
I tried a debug starting in the FormClosing event and and it seems as if the problem happens when the disposing method is called:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
}
base.Dispose(disposing);
When the DataGridView is being disposed its rows are being cleared of the data starting at the topmost row. This is when the exception is thrown.
I am stumped and any advice will be appreciated.Regards.
Kobus