DataTable dt = new DataTable();
if (listView1.Columns.Count == 0)
{
listView1.Items.Clear();//清空栏位
listView1.Columns.Add("请购单号", 115, HorizontalAlignment.Left); //新增栏位
listView1.Columns.Add("物料编码", 80, HorizontalAlignment.Left);
{
DataRow dr = dt.Rows[i];
ListViewItem lvi = new ListViewItem(dr["请购单号"].ToString().Trim());
lvi.SubItems.Add(dr["物料编码"].ToString().Trim());
lvi.SubItems.Add(dr["单位"].ToString().Trim());
lvi.SubItems.Add(dr["数量"].ToString().Trim());
listView1.Items.Add(lvi); //填充栏位数据
}
if (listView1.Columns.Count == 0)
{
listView1.Items.Clear();//清空栏位
listView1.Columns.Add("请购单号", 115, HorizontalAlignment.Left); //新增栏位
listView1.Columns.Add("物料编码", 80, HorizontalAlignment.Left);
}
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
ListViewItem lvi = new ListViewItem(dr["请购单号"].ToString().Trim());
lvi.SubItems.Add(dr["物料编码"].ToString().Trim());
lvi.SubItems.Add(dr["单位"].ToString().Trim());
lvi.SubItems.Add(dr["数量"].ToString().Trim());
listView1.Items.Add(lvi); //填充栏位数据
}