I write a foreach
loop to access the value of all cells in each row of datagridveiw, but I have an Error
"DataGridRow' does not contain a definition for 'Cells' and no accessible extension method 'Cells' accepting a first argument of type 'DataGridRow' could be found (are you missing a using directive or an assembly reference?)".
foreach (DataGridRow row in dataGrid_users.Rows)
{
// Retrieve cell values from the row
string name = row.Cells["name"].Valu?.ToString();
string surname = row.Cells["surname"].Value?.ToString();
string goal = row.Cells["goal"].Value?.ToString();
string operation = row.Cells["operation"].Value?.ToString();
string description = row.Cells["discription"].Value?.ToString();
string job = row.Cells["job"].Value?.ToString();
string station = row.Cells["station"].Value?.ToString();
string date = row.Cells["date"].Value?.ToString();
}
I think that the problem is that you wrote DataGridRow instead of DataGridViewRow in the foreach statement. Let me know if it works.