I have two forms, in Form1 a create objects from a class and puts into list (list of objects). then I have another list of strings which is supposed to be a source for
Change this:
Form2 lista = new Form2();
to something like this:
Form2 lista = new Form2(allPeopleSource);
Remove this from form2:
Form1 main = new Form1();
And put this code in form2
List allPeopleSourceInForm2;
Public Form2(List allSourcesAsParameter)
{
allPeopleSourceInForm2 = allSourcesAsParameter;
}
Now your code should work. What we are doing here, is bringing reference of a list to Form2. Form1 contains all the info and we are just passing address of this data to Form2. This reference is brought to Form2 as an constructor parameter. In Form2 constructor we can do what ever we want with data, but be noticed that all the changes into collection at form2 will affect also collection in Form1.