1、通过在别的窗体定义static变量  实现传值

winform定义static变量窗体传值winform定义static变量窗体传值

 

        private void button1_Click(object sender, EventArgs e)
        {
            //打开窗体
            要打开的窗体 fr = new 要打开的窗体();
            fr.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //接收打开的值并显示到自己的窗体中
            this.textBox1.Text = 要打开的窗体.strRes;
        }
 public static string strRes = "";
        private void button1_Click_1(object sender, EventArgs e)
        {
            //获取自己窗体的值
            string str = this.textBox1.Text;
            //将值付给静态变量
            strRes = str;
        }

 

相关文章:

  • 2022-01-12
  • 2022-12-23
猜你喜欢
  • 2021-07-04
  • 2021-12-19
  • 2022-12-23
  • 2021-11-28
  • 2021-10-08
  • 2022-02-23
相关资源
相似解决方案