Thats Close,
Lets say you have a string "sItemNumber" on form 1 and you want to
pass
that same string "sItemNumber" in form 2 to use as part of a SQL command.
Either use a property or a public method in Form 2 that accepts the string
as a parameter.
In both cases you need a reference to Form 2 to be able to access it.
In case of a common "parent" it might be better to call upon the parent to
pass on the string.
If Form 1 is the "parent" of Form 2 (you create Form 2 from within Form 1)
keep the reference to Form 2 for later use
Form2 f2 = new Form2();
f2.TextOnForm2 = "somestring";
f2.CreateSqlString("somestring");
if Form 2 is the parent form, pass 'this' when creating Form 1 and store
the "parent" in Form 1 for later use
Form1 f1 = new Form1(this);
public class Form1
{
Form2 parent = null;
public Form1(Form2 parent)
{
this.parent = parent;
}
}
and then use
parent.TextOnForm2 = "something";
parent.CreateSqlString("somestring");
This assumes Form2 has a property TextOnForm2 or a method CreateSqlString
public string TextOnForm2
{
get{}
set{}
}
public void CreateSqlString(string sourceString)
{
}