Click here to Skip to main content
15,904,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to :
When i click a button (xuiButton2) it opens a new form 2
it worked
and in form 2 there is a listbox
the items in that listbox are the same than the items in the other listbox

What I have tried:

I tried making that when alertfullscreen (my form 2) load it adds in listBox1 the items from the listBox1 of Form 1 but it didn't worked

Form 1:
private void xuiButton2_Click(object sender, EventArgs e)
{
    alertfullscreen form2 = new alertfullscreen();
    form2.Show();
}

form 2 :
private void alertfullscreen_Load(object sender, EventArgs e)
        {
            listBox1.Items = Form1.listBox1.Items;
        }
Posted
Updated 28-Jun-20 1:06am
v2

1 solution

Exactly how depends on the "relationship" between the two forms.
Have a look at these, one of them will fit your circumstances.
The form that creates an instance of another:
C#
MyForm mf = new MyForm();
mf.Show();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
So you want the first version: Parent to Child.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900