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.

I got it..thanks

You're very welcome. Please remember to mark this solved. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.