waffle

waffle

  • NA
  • 48
  • 0

adding unique items in listview

Apr 6 2007 3:46 AM
i have an ordering windows application. a product(including its quantity and price) is added to the listview when button is clicked. what i want to happen is when the product already exists in the listview, it will not add on the list but will just update the existing product info(quantity and price). how will i do this? i have this code for adding items in the listview... private void buttonAddItem_Click(object sender, EventArgs e) { ListViewItem pItem = new ListViewItem(listBoxItems.SelectedItem.ToString()); ListViewItem.ListViewSubItem sItem1 = new ListViewItem.ListViewSubItem(pItem, Convert.ToString(QuantityForm.quantity)); ListViewItem.ListViewSubItem sItem2 = new ListViewItem.ListViewSubItem(pItem, Convert.ToString(QuantityForm.quantity * Convert.ToInt16(labelItemPrice.Text))); pItem.SubItems.Add(sItem1); pItem.SubItems.Add(sItem2); listViewOrders.Items.Add(pItem); }

Answers (1)