我的自定义对象有两个属性:userid
和username
. 在这里,我找到了如何使用循环
遍历每个,但我不知道如何将当前单元格值分配给我的自定义对象值。DataGridViewRow
foreach
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
ClsOBJ userobj1 = new ClsOBJ();
foreach (DataGridViewCell dc in dr.Cells)
{
// userobj1.userid =
// cell index 0 should be read to userid
// and cell index 1 should be read to username
// userobj1.username =
}
list1.Add(userobj1);
}