ntabb 0 Newbie Poster

Hello all,

I have data grid on my form that shows errors accumulated during a computation. The table is populated as the program runs and I can add and remove rows from the table perfectly. I cannot, however, edit the values in the rows and have the changes show in the dataGridView that displays the table.

This is the edit method:

DataTable Messages = projectManager.getMessageTable();

for (int n = 0; n < Messages.Rows.Count; n++)
            {
                if (Messages.Rows[n].ItemArray[0].ToString() == code)
                {
                    Messages.Rows[n].ItemArray[1] = (object)description;
                    //MessageBox.Show(description);  //for diagnostics
                }
            }

I search the rows for the error code (the first column) and try to assign the new desciption once I find it. I've tested with Messages.AcceptChanges() as well to no avail. My refresh method looks like this:

errorGridView.Rows.Clear();

            for (int n = 0; n < Messages.Rows.Count; n++)
            {
                errorGridView.Rows.Add();
                errorGridView.Rows[n].Cells[1].Value = Messages.Rows[n].ItemArray[0];
                errorGridView.Rows[n].Cells[2].Value = Messages.Rows[n].ItemArray[1];
                errorGridView.Rows[n].Cells[3].Value = Messages.Rows[n].ItemArray[2];
                errorGridView.Rows[n].Cells[4].Value = Messages.Rows[n].ItemArray[3];
                errorGridView.Rows[n].Cells[5].Value = Messages.Rows[n].ItemArray[4];
            }

I do it this way (instead of dataSource) because I then add a column with a graphic indicating the type of error. The graphic addition method works fine; I've tested it thoroughly by forcing different tables at it.

Any ideas why when I call my edit method, the changes arent reflected in the refresh call?

Thanks,
NT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.