Send values from one form to another form

后端 未结 19 2500
眼角桃花
眼角桃花 2020-11-21 11:45

I want to pass values between two Forms (c#). How can I do it?

I have two forms: Form1 and Form2.

Form1 contains one button. When I click on that button, Fo

19条回答
  •  别跟我提以往
    2020-11-21 12:16

    This is very simple. suppose you have 2 window form Form1 and Form2 and you want to send record of textbox1 from Form1 to Form2 and display this record in label1 of Form2; then in Form2 create a label which name is label1 and go to the property of label1 and set 'Modifiers'=public and in Form one create a textBox with id textBox1 and a button of name submit then write the following code on button click event

    button1_Click(object sender, EventArgs e)
    {
      Form2 obj=new Form2();
      obj.label1.text=textBox1.text.ToString();
      obj.show();
    }
    

    thats it... for this way you can bind dataset record to another form's datagridview......

提交回复
热议问题