Form1里textBox输入字符后,点击Form2的button,Form1的textBox要在Form2以MessageBox.Show()现实传递值
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;代码如下:using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication12{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 myfrom2 = new Form2(); myfrom2.Show(); } }}using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication12{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form1 myform1 = new Form1(); MessageBox.Show(myform1.textBox1.Text); } }}但是最后MessageBox.Show()现实的是Form1的textbox 属性的值。而不是在textbox里输入的值,请问这是为什么?
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询