在我的项目中,有两种形式frmLogin
和frmMain
。从frmLogin
成功登录后,我表示做这样的事情的frmMain
形式提供给用户:显示与之前隐藏的形式
在frmLogin
形式button_click
事件:
frmMain main = new frmMain();
main.Show();
this.Hide();
在frmMain
当用户注销我想表现出同样的frmLogin
表格(不是实例)。这个怎么做?
我试过这段代码:(创造frmLogin
另一个例子,我不想)
在frmMain
形式button_click
事件:
if (MessageBox.Show("Do you really want to log out?", "Alert", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
{
this.FormClosing -= frmMain_FormClosing;
//
Process p = new Process();
p.StartInfo.FileName = Application.ExecutablePath;
p.Start();
//
this.Dispose();
}
我一直在使用internal
符也尝试过,但没有使用。
编辑:作为一名学员,我不允许使用Static
关键字和改变program.cs
。如果上述方法需要限制方法(我已提到),那么请给我一个替代方法。
试试这个。 http://stackoverflow.com/questions/3005732/showing-a-hidden-form – Sandeep