Jan 6, 2014

C# Transfering Data Between Forms

We Have Two Forms For Example.. 
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:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...