我希望用户先登录才能使用其他表单。但是我的困境在于,登录框在Form2中,而主表单在Form1中。
if ((struseremail.Equals(username)) && (strpasswd.Equals(password)))
{
MessageBox.Show("Logged in");
form1.Visible = true;
form1.WindowState = FormWindowState.Maximized;
}
else
{
MessageBox.Show("Wow, how did you screw this one up?");
}
然而,Form1不会变为可见状态(因为我将其启动为visible=false),在他们登录后。有人可以帮忙吗?
编辑:
非常好的回复,但我的问题仍然存在。我基本上想要首先加载Form2(这很容易,我运行Form1并将其设置为隐藏),但是当关闭Form2时,我也希望关闭Form1。
private void Form2_FormClosing(Object sender, FormClosingEventArgs e)
{
Form1 form1 = new Form1();
form1.Close();
MessageBox.Show("Closing");
}
这似乎不起作用...
form1.Close()
。 - this. __curious_geek