I'm working on a project where I've loaded a database into a DGV. I also have an additional unbound checkbox column for the users to select entries with. I have code in place to read the selected rows and save them into a CSV string, which is then saved in the usersettings. All this works fine.
I'm trying to reverse this effect so that when the DGV loads, the checkboxes that the user selected previously are checked (and the others left unchecked). I've debugged this extensively, and using watches have confirmed that all the values in the loops are right, and the conditionals are all kicking correctly, but it seems the code I'm using to actually check the boxes doesn't work. I've searched dozens of web pages, msdn white papers, and forums, but no suggestions will check the darned box. Below is some example code.
endingsi is an integer array used to crosscheck index values
Column 0 is an integer index value
Column 1 is the checkboxes in question (called "colSelected" in case necessary)
Column 2 is a description field (not used here)
For Each row as DataGridViewRow In dg.Rows For Each i As Integer In endingsi If row.Cells(0).Value = i Then Try row.Cells(1).Value = True Catch ex As Exception MsgBox("Failed: " + ex.Message) End Try End If Next Next
In debugging, it seems the value for the Cells IS changed, but the checkbox never gets selected. The try/catch was just to pick any error messages (but there are none with this code). What am I doing wrong here?