我正在尝试在从树视图中选择节点时填充列表视图,但是每次我选择节点时,它都会在列表视图中附加,我的 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() });
}
}