C# with DataGrids

What I have has a C# GUI App using a data grid to connect to a access database. I have add the check box to the datagrid and now what I'm trying to do is when the click submit I can loop through data grid and get the values that are check. The problems that I'm having is I can't figure out how to get just thoses values little lowe how to loop through the data grid.

Thank you for your help.

Thomas
thomasbonhamAsked:
Who is Participating?
 
surajgupthaCommented:
           for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null &&
                    dataGridView1.Rows[i].Cells[0].Value.ToString() == "True")
                {
                    MessageBox.Show(i.ToString()+" Selected");
                }
            }
0
 
dave4dlCommented:
loop through like:

foreach(DataGridItem objRecord in MyDataGrid.Items){
     doSomethingWithThis(objRecord.Cells[0].Controls["MyCheckbox"].value);
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.