Rya*_*ant 6 .net c# forms login winforms
我有一个系统,其中主窗体是菜单,并在加载时弹出登录表单.最初它加载了菜单下面的登录表单,所以我使用this.topmost = true来使它出现在前面.(因为带到前面并且发送回来不起作用)
但是,如果用户然后单击其他内容(例如chrome),则根据最顶层的定义,它仍然位于z顺序的顶部.
我尝试使用deactivate事件,但这意味着在加载时它再次出现在菜单表单后面.
我怎么能阻止它加载到我的菜单表格后面,但是当它失去焦点时它会阻止它成为最顶层的?
private void login_Deactivate(object sender, EventArgs e)
{
// do not want it to remain top most when the application is not in focus.
this.TopMost = false;
}
Run Code Online (Sandbox Code Playgroud)
在菜单表格中:
private void Menu_Load(object sender, EventArgs e)
{
openLogin()
}
private void openLogin()
{
Cursor.Current = Cursors.WaitCursor;
login theForm = new login(this);
this.Enabled = false;
theForm.Show();
Cursor.Current = Cursors.Default;
theForm.Activate();
theForm.TopMost = true; // Make the login form display over the Menu
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
417 次 |
| 最近记录: |