Set value to another form

后端 未结 4 1699
清歌不尽
清歌不尽 2021-01-21 12:50

I have to form Form1 and Form2

Form1 source

namespace WindowsFormsApplication1
{
    public partial class Form1 :          


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 13:13

    Use Constructor method , here is example

    In form2

    public Form2(string strTextBox)
    {
     InitializeComponent(); 
     label1.Text=strTextBox;
    }
    

    In form1 click event

    private void label1_Click(object sender, System.EventArgs e)
    {
    Form2 frm=new Form2(textBox1.Text);
    frm.Show();
    }
    

    For more information , reference Passing Data Between Forms !

提交回复
热议问题