There are many ways to do this... first of, you could use some sort of parent/child structure... When creating the new form2(), you'd p!@#$%^&* 'this' as parameter, that would refer to the current form (parent) //in mainform (parent)
//All the values you need to access from the child form should be public in mainform
public int valueToUse1;
public int valueToUse2;
public string stringToUse;
...
[...]
//P!@#$%^&* a reference to the current class (mainform, in this case) when constructing your new form
Form childform = new form2(this);
[...]
//in form2 (child)
private object parentform;
public form2(object parent)
{
parentform = parent;
}
public void somemethod()
{
//Now you can refer to any public members of the mainform... can be either variables, or methods
if (parent.valueToUse1 == parent.valueToUse2)
parent.somePublicMethod();
else
{
int sampleInt = parent.calculateSomething();
//dostuff or whatever
}
} Another thing you can do is have all the values you need to p!@#$%^&* on be part of a struct (or class), and you could just p!@#$%^&* that object to your form, which might simplify some things. But it's less pretty imo I'm not an OO programming beast yet, so there might be a better way to do it... But anyway, usually you'd want to avoid having too much algorythm stuff going on in your form code itself, and you'd have other classes taking care of that... and in your case, both forms would use the same instance of that class... And the form would just send form input to the class and get whatever results you need from it. So yeah I think that would be even better...