首先一个全局变量:
private delegate void AddListView(ListViewItem Itmes);
然后一个添加方法:
private void AddListViews(ListViewItem listView)
{
if (this.listView1.InvokeRequired)
{
var _addListView = new AddListView(this.AddListViews);
this.listView1.Invoke(_addListView, listView);
}
else
{
this.listView1.Items.Add(listView);
}
}
调用如下:
string t1=“1”;
string t2=“2”;
string t3=“3”;
string t4=“4”;
string t5=“5”;
this.AddListViews(new ListViewItem(new[] { t1, t2, t3, t4, t5 }));