Send values from one form to another form

后端 未结 19 2495
眼角桃花
眼角桃花 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:04

    How to pass the values from form to another form

    1.) Goto Form2 then Double click it. At the code type this.

    public Form2(string v)
    {
      InitializeComponent();
      textBox1.Text = v;
    }
    

    2.) Goto Form1 then Double click it. At the code type this. //At your command button in Form1

    private void button1_Click(object sender, EventArgs e)
    {
       Form2 F2 = new Form2(textBox1.Text);
       F2.Show();
    }
    

提交回复
热议问题