public void ListViewSubItemCollection_RemoveAt_ValidIndex_Success() { var item = new ListViewItem(); var collection = new ListViewItem.ListViewSubItemCollection(item); var subItem = new ListViewItem.ListViewSubItem(); collection.Add(subItem); collection.Add(new ListViewItem.ListViewSubItem()); collection.Add(new ListViewItem.ListViewSubItem()); collection.Add(new ListViewItem.ListViewSubItem()); // Remove from start. collection.RemoveAt(0); Assert.Equal(3, collection.Count); // Remove from middle. collection.RemoveAt(1); Assert.Equal(2, collection.Count); // Remove from end. collection.RemoveAt(1); Assert.Single(collection); // Remove only. collection.RemoveAt(0); Assert.Empty(collection); Assert.Same(item, subItem.owner); }
public void ListViewSubItemCollection_RemoveAt_InvalidIndexEmpty_ThrowsArgumentOutOfRangeException(int index) { var item = new ListViewItem(); var collection = new ListViewItem.ListViewSubItemCollection(item); Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.RemoveAt(index)); }
/* private void Listview1_ItemChecked(object sender, ItemCheckedEventArgs e) * { * foreach (ListViewItem Item in ListView1.Items) * { * if (Item != null) * { * if (Item.Checked == true) N++; * } * } * Textbox1.Text = N.ToString(); * } * * * ListView.CheckedListViewItemCollection checkedItems = * ListView1.CheckedItems; * * foreach ( ListViewItem item in checkedItems ) * { * value = item.SubItems[1].Text; * } */ private void ApproveButton_Click(object sender, EventArgs e) { // Get selected row ListView.CheckedListViewItemCollection checkedItems = ContractList.CheckedItems; foreach (ListViewItem item in checkedItems) { ListViewItem.ListViewSubItemCollection listSubItem = item.SubItems; listSubItem.RemoveAt(0); int contractID = int.Parse(listSubItem[0].Text); RentContract contract = manage.FindContractById(contractID); if (checkContractValidity(contract)) { updateApprovalStatusInDatabase(contractID); ListViewItem approvedItem = new ListViewItem(); foreach (ListViewItem.ListViewSubItem subItem in listSubItem) { approvedItem.SubItems.Add(subItem); } // remove it from the left listview ContractList.Items.Remove(item); // Add it to the right listview ApprovedContractList.Items.Add(item); } //manage = Program.LoadData(); //setUpGUI(); // Get the removed item id and change the APPROVED to TRUE in the database: } }
public void RemoveAt(int index) { collection.RemoveAt(index); }