I like to reach all the cells by column name in a loop( foreach...) and
compare the content of the cell in datetime type and add a value to another cell depending on the result of the comparison. I do this for all the populated rows.
Question is how do I locate a particular cell in each row.
A DataGridView has a Rows property which is of type DataGridViewRowCollection. You could use that if you want.
Usually I just index like this : dataGridView[0, 2].Value = something...
Which is the first cell of the third row.
with - dataGridView[0, 2].Value = something... - you are assuming that you know the indexes of row and column. If it is sequential reading of grid with foreach, I mean the whole table, it should come from program. And column index I have to find it by giving the column name. So it is current row and index by column name. I hope I made myself clear.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...