Devexpress GridControl如何遍历所有行
List<Medicine>medicinelist=newList<Medicine>();foreach(DataGridViewRowrowinthis.gridC...
List<Medicine> medicinelist = new List<Medicine>();
foreach (DataGridViewRow row in this.gridControl1)
{
if (row.Cells[0].Value != null && (bool)row.Cells[0].Value == true)
{
Medicine medicine = new Medicine();
medicine.Hiscode = row.Cells[1].FormattedValue.ToString();
medicine.Hisname = row.Cells[2].FormattedValue.ToString();
medicine.Hisscalctype = row.Cells[3].FormattedValue.ToString();
medicine.Hisspec = row.Cells[4].FormattedValue.ToString();
medicine.Hisunits = row.Cells[5].FormattedValue.ToString();
medicine.IsMedTre = true;
medicinelist.Add(medicine);
}
}
在foreach里边,报错了! 展开
foreach (DataGridViewRow row in this.gridControl1)
{
if (row.Cells[0].Value != null && (bool)row.Cells[0].Value == true)
{
Medicine medicine = new Medicine();
medicine.Hiscode = row.Cells[1].FormattedValue.ToString();
medicine.Hisname = row.Cells[2].FormattedValue.ToString();
medicine.Hisscalctype = row.Cells[3].FormattedValue.ToString();
medicine.Hisspec = row.Cells[4].FormattedValue.ToString();
medicine.Hisunits = row.Cells[5].FormattedValue.ToString();
medicine.IsMedTre = true;
medicinelist.Add(medicine);
}
}
在foreach里边,报错了! 展开
2个回答
展开全部
不应该用this.gridControl1,而应该用this.gridView1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询