C# winform在一个窗体中如何设置另一个窗体的TextBox的值
				
									
					
					
						|  | 
							admin 2017年3月9日 15:34
								本文热度 8126 | 
					
				 
				
方法有很多,下拉给你列几个:
 1 | 
 
publicSystem.Windows.Forms.TextBox textBox1;
 | 
在调用时就能直接访问
 1 
 2 
 3 | 
 
Form1 frm = newForm1();
 frm.textBox1.Text = "方法1";
 frm.Show();
 | 
 1 
 2 
 3 
 4 
 5 
 6 | 
 
publicForm2(stringtext)
 {
     InitializeComponent();
       this.textBox1.Text = text;
 }
 | 
调用时
 1 
 2 | 
 
Form2 frm = newForm2("方法2");
 frm.Show();
 | 
 1 
 2 
 3 
 4 
 5 | 
 
publicstringText3
 {
     get{ returnthis.textBox1.Text; }
     set{ this.textBox1.Text = value; }
 }
 | 
调用如下
 1 
 2 
 3 | 
 
Form3 frm = newForm3();
 frm.Text3 = "方法3";
 frm.Show();
 | 
等等,还有一些其他方法,这不一一介绍了。
 
该文章在 2017/3/9 15:34:05 编辑过