关于在一个类(窗体)中调用另一个类(窗体)中的控件的三种方法

个人认为第三种比较好
A.设置构造函数参数
//窗体2中的构造函数
public form2(string str) {
   InitializeComponent();
   this.textBox1.Text = str;
}

B.在需要调用的类中设置静态方法并调用
public class form2 : form {
   public static setTextbox1(string str) {
      this.textBox1.text = str;
   }
}
然后在form1中调用该方法进行设置
C.将声明TextBox的时候,权限改成public或者包访问

posted @ 2006-11-12 05:40  飘啊飘  阅读(3166)  评论(4编辑  收藏  举报