


例如
- Form1 form1 = new Form1();
- form1.Button; //调用控件
- form1.Method(); //调用方法
当然了,控件的Modifiers属性要设置成public
另一种是不创建窗体对象
在Form1类下定义静态变量,构造方法中引用这个Form1
- class Form1: Form
- {
- public static Form1 form1;
- public Form1()
- {
- InitializeComponent();
- form1 = this;
- }
- public void Method()
- {
- }
- }
调用该窗体的控件或方法
- Form1.form1.Button;
- Form1.form1.Method();



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论