internal override void SetError(ListView list, ref ListViewItem item, string strBarcodeOrRecPath, string strError) { // 确保线程安全 2014/9/3 if (list != null && list.InvokeRequired) { Delegate_SetError d = new Delegate_SetError(SetError); object[] args = new object[4]; args[0] = list; args[1] = item; args[2] = strBarcodeOrRecPath; args[3] = strError; this.Invoke(d, args); // 取出 ref 参数值 item = (ListViewItem)args[1]; return; } if (item == null) { item = new ListViewItem(strBarcodeOrRecPath, 0); list.Items.Add(item); } else { Debug.Assert(item.ListView == list, ""); } // item.SubItems.Add(strError); ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError); SetItemColor(item, TYPE_ERROR); // 将新加入的事项滚入视野 list.EnsureVisible(list.Items.IndexOf(item)); }
void Safe_setError(ListView list, string strError) { Delegate_SetError d = new Delegate_SetError(SetError); this.Invoke(d, new object[] { list, strError }); }