2

我正在尝试在从树视图中选择节点时填充列表视图,但是每次我选择节点时,它都会在列表视图中附加,我的 Listview.Items.Clear() 函数不起作用。我的代码:

listView1.Clear();
            if (this.treeView1.SelectedNode.Tag != null)
            {
                string msg = this.treeView1.SelectedNode.Tag.ToString();
                int complaint_id = Convert.ToInt32(msg);
                PopulateDataTable2(complaint_id);
                foreach (DataRow row11 in dsTreeView_Info.Tables["Complaints_Info"].Rows)
                {
                    listView1.Items.Add(new ListViewItem() { Text = row11["Complaint_Descriptions_Info"].ToString() });
                }
            }
4

1 回答 1

0

我没有在forecah之后清除数据集。所以它的项目不断添加。

 dsTreeView_Info.Clear();

谢谢“DJ KRAZE”。

于 2013-02-01T09:30:00.853 回答