Kevin Brigitta

Kevin Brigitta

  • NA
  • 43
  • 49.7k

Adding counted items to a listbox from another listbox

Jun 18 2011 7:39 AM
Hi,

- I have a listbox, called "lbox_Products".
- Next to this box, I have a button "btn_AddProduct".
- I have another listbox, called "lbox_SelectedProducts"

When I select an item in my lbox_Products, and I click on the btn_AddProduct, the selected item from the first lbox_Products, is put in the other lbox_SelectedProducts.

This happens like this:

        private void btn_AddProduct_Click(object sender, RoutedEventArgs e)
        {
            lbox_SelectedProducts.Items.Add(lbox_Products.SelectedItem);
        }

This works fine, but what I want to do, is have a single line for each product in lbox_SelectedProducts, preceeded by the number of times that it has been added.

For example:

1 phone
3 displays
6 computers
2 speakersets
...

How can I do this...?

Answers (9)