【发布时间】:2014-01-10 05:18:18
【问题描述】:
我正在开发一个用 C# 编写的 Windows 窗体应用程序。
我发现有人建议如何从DataGridView 控件创建List<>,但我需要更多关于如何提取单元格值的帮助。
这是给出的代码;假设dataGridView1 中的两列是Name 和Address。
如何构建List<ProjList> 对象?
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
ProjList = new List<ProjectMasterRec>();
foreach (DataGridViewCell dc in dr.Cells)
{
// build out MyItem
// based on DataGridViewCell.OwningColumn and DataGridViewCell.Value
// how do we code this?
}
ProjList.Add(item);
}
【问题讨论】:
-
是否要获取所有行列数据并以字符串的形式作为一条记录插入到列表中?
标签: c# winforms list datagridview custom-object