首页 > 其他分享 >循环遍历DataGridView各行某列数据

循环遍历DataGridView各行某列数据

时间:2022-11-08 19:03:44浏览次数:33  
标签:遍历 某列 Cells Value DataGridView dgr Column1


循环遍历DataGridView各行某列数据

如此做

foreach (DataGridViewRow dgr in dataGridView1.Rows)
{
if (dgr.Cells["Column1"].Value == null)
{
break;
}
label1.Text += dgr.Cells["Column1"].Value.ToString() + " ";
}

若某行某列无值,​​dgr.Cells["Column1"].Value.ToString()​​获取值就会异常。


标签:遍历,某列,Cells,Value,DataGridView,dgr,Column1
From: https://blog.51cto.com/u_13654233/5834446

相关文章