how to communicate data between forms?

后端 未结 4 708
后悔当初
后悔当初 2021-01-23 18:51

I want to pass some values to different forms at there button click event. plz guide me.I am using c sharp.net 2005,win forms. I want to access the value in a sql query in form

4条回答
  •  醉话见心
    2021-01-23 19:20

    Try this code, you have to do something like following code : inside this event you have to pass data to other

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 secondForm = new Form2();
            secondForm.YourProperty = "This is your data";
            secondForm.Show();
        }
    

    In the other form you have to declare a property :

        public string YourProperty { get; set; }
    

    hope this help.

提交回复
热议问题