public void KillCommand() { try { List <ListViewItem> killed = new List <ListViewItem>(); foreach (ListViewItem item in mainForm.CommandspendingListView.SelectedItems) { UInt32 commandID = Convert.ToUInt32(item.SubItems[(int)CommandsColumns.COMMANDID].Text); if (MOG_ControllerSystem.KillCommandFromServer(commandID)) { killed.Add(item); } } foreach (ListViewItem item in killed) { item.Remove(); } } catch (Exception e) { MOG_Report.ReportMessage("Kill Command Error", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR); } }