// ----- ITEM POPULATION ----- // #region Item Population public void PopulateItems(List <WorkflowItem> workflowItems, List <string> excludedIDs) { idsAddedToLv = new List <string>(); excludedWfItems = new List <WorkflowItem>(); workflowItemsLoaded = new List <WorkflowItem>(); int itemsNotShowing = 0; // save lists to this instance this.workflowItems = workflowItems; this.excludedIDs = excludedIDs; // set excluded items as wf items or notify user they cannot be set try { excludedWfItems = GetItemsToDisplayFromIDs(); workflowItemsLoaded = excludedWfItems; } catch (Exception) { MessageBox.Show("Could not load items. Ensure ID list is in the correct format"); } // reset lv this.itemsListView.BeginUpdate(); this.itemsListView.ListViewItemSorter = null; this.itemsListView.Items.Clear(); // column headers this.viewColumnHeader1.Text = ""; this.viewColumnHeader2.Text = "Item ID"; this.viewColumnHeader3.Text = "Company Name"; this.viewColumnHeader4.Text = "Sent Date"; this.viewColumnHeader5.Text = "From Address"; this.viewColumnHeader6.Text = "Subject"; this.viewColumnHeader7.Text = "Status"; SetInitialColumnHeaderSizes(); // for each id in the list foreach (string excludedID in excludedIDs) { // if list does not already contain item if (!idsAddedToLv.Contains(excludedID)) { // if workflow items are available, show entire items in LV if (workflowItems != null && workflowItems.Count > 0) { // if item is available if (this.GetWorkflowItemByID(excludedID) != null) { // get the item from the id string WorkflowItem wfItem = this.GetWorkflowItemByID(excludedID); // make tmp lvItem ListViewItem lvItem = new ListViewItem(itemNum.ToString()); // add to tmp lvItem lvItem.SubItems.Add(wfItem.DocumentWorkflowItemID.ToString()); lvItem.SubItems.Add(wfItem.VendorName); lvItem.SubItems.Add(wfItem.EmailDate.ToString()); lvItem.SubItems.Add(wfItem.EmailFromAddress); lvItem.SubItems.Add(wfItem.SubjectLine); lvItem.SubItems.Add(wfItem.Status); // add lvItem to lv itemsListView.Items.Add(lvItem); // add string to added lv ids idsAddedToLv.Add(excludedID); } else { ++itemsNotShowing; } } // if workflow items aren't available, just show IDs instead else { // make tmp lvItem ListViewItem lvItem = new ListViewItem(itemNum.ToString()); // add ID to tmp lvItem lvItem.SubItems.Add(excludedID); // add lvItem to lv itemsListView.Items.Add(lvItem); } altMain.CountListViewItems(itemsListView); this.itemsListView.ListViewItemSorter = lvwColumnSorter; this.itemsListView.EndUpdate(); CorrectColumnHeaderSize(viewColumnHeader6); } } // display items not showing count if > 0 if (itemsNotShowing > 0) { if (itemsNotShowing == 1) { SetStatusLabelAndTimer($"{itemsNotShowing} item on the file cannot displayed. Item ID doesn't correlate with any item in the current view."); } else { SetStatusLabelAndTimer($"{itemsNotShowing} items on the file cannot displayed. Item ID's don't correlate with any items in the current view."); } } }