Form1
Form2
In Form1 You Will Have To Insert A Coding Like This Inside A Event Where Ever You Like It To Be. I Have Choosed It To be Under The Button Click Event.
I Have A Variable In Form1 And Form 2.
Form1 Variable is public string form1variable;
Form2 Variable is public string form2variable;
Now Lets See How To Get Data From Another Form.
private void button1_Click(object sender, EventArgs e)
{
using (Form2 f2 = new Form2())
{
//Below We have To Open Form 2 To Get Them To Form1.
f2.ShowDialog();
{
form1variable = f2.form2variable;
} //When We Close The Form2 We Will Get The Data in form2variable to form1variable.
//Make Sure Data Is Loaded To form2variable.
}
}
------------------------------------------------------------------------------------------------------------
Now Lets See How To Send Data To Another Form.
private void button1_Click(object sender, EventArgs e)
{
using (Form2 f2 = new Form2())
{
f2.form2variable = form1variable;//Setting Form1 variable to Form2
}
}
------------------------------------------------------------------------------------------------------------
If You Have Any Problem Please Comment Below
No comments:
Post a Comment