/// <summary> /// When the user selects a tub or machine, enable the "assign" /// button if both lists have an item selected. /// </summary> /// <param name="sender">ignored</param> /// <param name="e">ignored</param> private void SelectChanged(object sender, EventArgs e) { ListView lv = (ListView)sender; ListView.SelectedListViewItemCollection c = lv.SelectedItems; foreach (ListViewItem i in lv.Items) { if (c.Contains(i)) { i.BackColor = SystemColors.Highlight; i.ForeColor = SystemColors.HighlightText; if (sender.Equals(MachineList())) { _selectedMachine = i; } if (sender.Equals(TubList())) { _selectedTub = i; } } else { i.BackColor = Color.Empty; i.ForeColor = Color.Empty; } } AssignButton().Enabled = MachineList().SelectedItems.Count > 0 && TubList().SelectedItems.Count > 0; }
public void edit(ListView.SelectedListViewItemCollection listItemsToEdit) { for(int count=0;count<listItems.Length;count++) { if(listItemsToEdit.Contains(listItems[count])) { edit(items[count]); } } }
// deletes a few particular items public void delete(ListView.SelectedListViewItemCollection listItemsToDelete) { Object[] newItems=new Object[items.Length-listItemsToDelete.Count]; ListViewItem[] newListItems=new ListViewItem[items.Length-listItemsToDelete.Count]; int increment=0; for(int count=0;count<listItems.Length;count++) { if(listItemsToDelete.Contains(listItems[count])) { delete(items[count]); view.Items.Remove(listItems[count]); } else { newItems[increment]=items[count]; newListItems[increment]=listItems[count]; increment++; } } items=newItems; listItems=newListItems; }
public Boolean Contains(GenericListViewItem <T> item) { return(_items.Contains(item)); }