Form1 is a pop out windows from Form2.
Form1 has a listbox1 with items and when I clicked the 'Continue' button in Form1, it will pass all the items in the listbox1 to listbox2 which is located in Form2.

I would like to ask how the button_click in Form1 will pass the listbox1's items to Form2's listbox2.

Thanks

Add on: the Form2 I stated above is not exactly a form, it is a panel for Form2, let just called it panel2

Thanks

In Form1 make the listbox modifiers property public. Make the continue button the Accept Button. Make the formborderstyle fixeddialog. Make StartPosition CentreParent.

Use this code in Form2:

        Form1 NewForm = new Form1();
        NewForm.ShowDialog();
        listBox1.Items.Clear();
        listBox1.Items.AddRange(NewForm.listBox1.Items);

Showdialog makes form1 tied to form2, until it is closed.
When you click the continue button the new form1 will close and the listbox on form2 will contain the items from the listbox on form1. It shouldn't matter if the the listbox on form2 is in a panel. As long as you can access it's properties this will work.

Edited 3 Years Ago by tinstaafl

This question has already been answered. Start a new discussion instead.