可以在a中进行控制Form public,但不推荐,您可以执行以下操作:
1)以第一种形式(form1)ButtonFirstFormClicked声明一个新事件
public event EventHandler ButtonFirstFormClicked;
Run Code Online (Sandbox Code Playgroud)
并在Button.Click事件处理程序中触发此事件
void button_Clicked(object sender, EventArgs e)
{
// if you're working with c# 6.0 or greater
ButtonFirstFormClicked?.Invoke(sender, e);
// if you're not then comment the above method and uncomment the below
//if (ButtonFirstFormClicked!= null)
// ButtonFirstFormClicked(sender, e);
}
Run Code Online (Sandbox Code Playgroud)
2)在第二种形式(form2)中订阅事件
form1.ButtonFirstFormClicked += (s, e)
{
// put your code here...
}
Run Code Online (Sandbox Code Playgroud)
祝好运!