Monday, 7 September 2015

Passing value from one forms to another forms in window application using C#

Note => This code will be written in first form  and we will create object of second form where we want to send value 

                    String StrValue="I love C#"
                    FrmNameSecond   frm = new  FrmNameSecond ();
                    frm.openform(StrValue); //openform is method of second form
                    this.Hide(); // This will hide current window 
                    frm.ShowDialog();  //Shows the form as a modal dialog box.
                    this.Show(); // this will show Second form window

Note =>  frm.openform is a method  , So i have called this method becoz i want "StrValue" to my next form class "FrmNameSecond" .

I have created method like this and i get my value 

       public void openform(string StrValue)
        {
          string  FirstfrmValue = StrValue;
        }

No comments:

Post a Comment