C# 有form1 和form2 form1如何获得form2的textbox 中的值
在Form1中
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public partial class Form1: Form { Form2 form2; private void button1_Click( object sender, EventArgs e) { if (form2 == null ) form2 = new Form2(); form2.Show( ); } private void button2_Click( object sender, EventArgs e) { //点击button2获取form2中textBox1的内容 if (form2 == null ) return ; string s = form2.Message; //详见Form2类中的定义 } } |
在 Form2中
| 1 2 3 4 5 6 7 8 | public partial class Form2: Form { //添加Message public string Message { get { return textBox1.text;} } } |
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
