Friday 12 April 2013

Passing value from one form to other ....

Form 1 code...:-

namespace Passing_values_from_one_form_to_other
{
    public partial class Form1 : Form
    {
        string str;
        private String value1;//taking values from form no _of_test_cases

        public string value
        {
            get { return value1; }
            set { value1 = value; }
        }


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            
            textBox1.Text = str;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.ShowDialog();
            str = f2.passvalue;
        }
    }
}


Form 2 code....:-


namespace Passing_values_from_one_form_to_other
{
    public partial class Form2 : Form

    {
         private string str;
        public string passvalue
        {
            get { return  str; }
            set { str = value; }
        }
    
        public Form2()
        {
            InitializeComponent();
        }

        private void Btn_Ok1_Click(object sender, EventArgs e)
        {

            passvalue = textBox1.Text;
            this.Close();

        }
    }
}


directly execute it u will get the clear picture....same way u can pass values from one form to other...

post your comments if you face any issues...

hope this will help...

or else you can refer this video...

http://www.youtube.com/watch?v=PI3ad-TebP0


0 comments:

Post a Comment