/// <summary> /// リストビューにアイテムを追加する /// </summary> /// <param name="lv">リストビュー</param> /// <param name="li">アイテム</param> public void AddItemToListView(ListView lv, ListViewItem li) { if (lv.InvokeRequired) { var d = new AddItemToListViewCallback(AddItemToListView); lv.Invoke(d, new object[] { lv, li }); } else { lv.Items.Add(li); } }
private void AddItemToListView(ListView lv, ListViewItem lvItem) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.labelStatus.InvokeRequired) { AddItemToListViewCallback d = new AddItemToListViewCallback(AddItemToListView); this.Invoke(d, new object[] { lv, lvItem }); } else { lv.Items.Add(lvItem); lv.Update(); } }