Visual Studio 2013,Visual C#,Windows窗体应用程序.
我对两个Form类感兴趣.该AfterTheGameForm.cs和TheGameForm.cs.
只有当用户点击第二个按钮时,第一个弹出窗口才会弹出.
AfterTheGameForm afterTheGameForm = new AfterTheGameForm();
afterTheGameForm.Show(this);
Run Code Online (Sandbox Code Playgroud)
所以很明显TheGameForm是AfterTheGameForm的所有者.这就是我的问题...... 在AfterTheGameForm类中, 我想引用Owner类以使用它的特定方法.我肯定知道所有者属于TheGameForm,我正在尝试施放:
TheGameForm gForm = (TheGameForm)this.Owner;
if(gForm!=null){
MessageBox.Show(theGameForm.CheckedRadioButton);
}
else
{
MessageBox.Show("theGameForm==null");
}
Run Code Online (Sandbox Code Playgroud)
我也试过这个演员:
TheGameForm gForm = this.Owner as TheGameForm;
Run Code Online (Sandbox Code Playgroud)
gForm对象为null!怎么可能?
| 归档时间: |
|
| 查看次数: |
433 次 |
| 最近记录: |