在登录表单中填写表单 [英] Formclosing in Login form
问题描述
大家好,
我有两种表格的申请:登录和主体。
当我在我的应用程序午餐时,出现我的登录表单,我输入用户名和密码。
问题是当我使用不正确的凭据关闭我的登录表单时,会出现第二个表单。
所以,我用这段代码插入formclosingevent:
Hello everyone,
I have an application with two forms: login and mainform.
When I lunch my app, appears my login form where I put username and password.
The problem is that when I close my login form using incorrect credentials, the second form appears.
So, I insert the "formclosingevent" with this code:
DialogResult warning = MessageBox.Show("Exit?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (warning == DialogResult.Yes)
{
Application.Exit();
}
else
{
e.Cancel = true;
}
因此,用户必须写出正确的凭据才能输入我的第二个表格。
但问题是:当我写出正确的凭据时,我的第二个表单出现了,但登录的表单向我询问我之前写的消息(DialogResult warning = MessageBox.Show(Exit?, 警告..)。
如果凭证合适,我该如何隐藏消息?
So the user must to write right credentials to enter in my second form.
But the problem is: when I write right credentials, my second form appears, but the login's form ask to me the message that I wrote before (DialogResult warning = MessageBox.Show("Exit?", "Warning".. ).
How can I do to hide the message when credentials is okay ?
推荐答案
Formclosing是一个在将要卸载表单时调用的事件。您可以将对DialogBox的调用放在一个条件中,该条件检查已按下哪个按钮(带有标志或类似按钮)。
Formclosing is an event that is called any time the form is about to be unloaded. You sould put the call to DialogBox inside a condition that checks which button has been pressed (with a flag or similar).
看看这个:如何实施登录表单和主表单 [ ^ ]
这篇关于在登录表单中填写表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!