I am working on a project with a total of 6 forms. One form is the main form and the other 5 are part of its option menu. The forms on the options menu are for changing settings and modifying data that is used in the main form.
For example, user clicks on option to change settings, new form pops up with the current settings, then user can modify the settings and apply the changes. When the user returns to the main form the settings should be changed.
What I would like to do is send the current settings data from the main form into the components of the new form, after the user applies the changes and closes the new form the data is sent and updates the main form’s components.
One Specific case I am trying to do is put data into a listbox on the other form from an arrayList created and initialized in the main form. I have been trying code like this example:
string data = somestring;
newForm.Controls[2].Add(data);
But I do not seem to have access to methods like Add and Insert for newForm.Controls[2], so the code fails.
My other thought was to create a method in the new form and send the data to it that way, but the method is not recognized as existing in the main form. I get this error:
'System.Windows.Forms.Form' does not contain a definition for 'AddToList'
To send data what you can do is in the constructor of your option form, take in parameters.
eg
Then, the simplest method to get data back out is to include public properties in your OptionsForm class containing whatever information you need.
In fact, with the public properties, you could also set the properties this way.
Hope this is what you meant