Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有 Form1 和 Form2,并且我button1_Click在 Form1 中有事件,那么:
button1_Click
System.Void button1_Click(System.Object sender, System.EventArgs e) { static boolean x= false; .. .. Form2.Show(); }
我想在关闭Form2时,把x = true,怎么做
Form2 otherForm = new Form2(); bool x = false; otherForm.FormClosing += (s,args)=> x = true;
您需要更改x为公共静态property或field. x应该在类级别声明以使其对其他类可见。
x
property
field
然后,只需根据需要从 From2 更新静态属性。