Hello all, I have run into a problem... I am trying to call a method from a thread but it is throwing an exception... System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="System.Windows.Forms"
Here is the code: public void zap_publish_listview(zap item) { if (listView_main.InvokeRequired) { SetZapPublishListview s = new SetZapPublishListview(zap_publish_listview); Invoke(s, new object[] { item }); } else { // Extract data from zap item int icon = getStatusIconNumber(item.zap_state.ToString()); string name = item.zap_channel.ToString(); string data = item.zap_state.ToString(); // Create listview item ListViewItem lvItem = new ListViewItem("", icon); lvItem.SubItems.Add("ZAP: " + name); lvItem.SubItems.Add(data); lvItem.ToolTipText = item.ToString(); lvItem.Group = listView_main.Groups[2]; // ZAP group is index 2 // Find location of listview item to be replaced ListViewItem old_item = listView_main.FindItemWithText("ZAP: " + name, true, 0); // If item exists if (old_item.Index >= 0) { // Insert listview item listView_main.Items.Insert(old_item.Index, lvItem); // Remove old item listView_main.Items.RemoveAt(old_item.Index); } else { // Insert listview item listView_main.Items.AddRange(new ListViewItem[] { lvItem }); } } }
I have a similar method that updates a debug window... And that works fine... Can anyone help??? Thanks in advance, Phil
"Rules are for the obedience of fools and the guidance of wise men"