-2

Scenario - In form A, user select sample/s and quantity and add it cart button. When you click on the add to cart button, it goes to form B where one could see the selection and then if they want to add more sample, they click go back.

Now I am not sure how to save user selection, because if I go back, it removes all data. I am newbee to this.

Please advise. My code -

form A

Form2 screen = new Form2(sample_array, quantity_array);             
screen.ShowDialog(); 

form B

void populate_listview(string[] sample_name, string[] qty_amt)
    {
        for (int i = 0; i < lib_name.Length; i++)
        {
            string[] subitems = new string[] { sample_name[i], qty_amt[i] };
            ListViewItem item = new ListViewItem(subitems);
            listView1.Items.Add(item);      

        }     

    }

What code should I add so that it saves the current list and then append to new user selection.

user3613720
  • 47
  • 1
  • 9
  • 1
    We can't see your screen, and you have not described your problem in enough detail for us to understand what you want. If you don't know how to pass a selection in one form to another form, consult [Passing Values Between Windows Forms](http://stackoverflow.com/questions/17836398/). – Dour High Arch Jun 02 '15 at 17:01
  • I know how to pass values from one form to other. I want to create a add cart feature. Form B is where all the values get displayed and so if a user want to add more values then they must go back form A to select more values. But I don't know how to save previous selection in Form B and append new user selection to it. – user3613720 Jun 02 '15 at 17:51

1 Answers1

0

Basically, you have to use a content presenter inside your page and notify the main page (the one with the cart and all selected items) via Event Publisher!

enter image description here

You can find details about Content Presenter here : Content Presenter

and about events here : events

Dragos Stoica
  • 1,753
  • 1
  • 21
  • 42