I have to forms and an arraylist
when i want to access to arraylist from another form
I cant access arraylist's items .
I define all of them public .
source code is here
Printable View
I have to forms and an arraylist
when i want to access to arraylist from another form
I cant access arraylist's items .
I define all of them public .
source code is here
You need to have a reference to the form 1 that is already created. You are making a new form1 object, but that isn't the same form1 that opened form2.
In Form2 constructor add in a argument that you can pass in a current reference the form that is creating this form
Now, in form1, when you create a form2 object, you pass in a reference of itself:Code:private Form1 fm1;
public Form2(Form1 myFrm)
{
InitializeComponent();
fm1 = myFrm;
}
Code:Form2 fm2 = new Form2(this) ;
Thank you very much