在第二种形式中单击按钮时重新显示初始屏幕
本文关键字:新显示 显示 按钮 屏幕 二种 单击 | 更新日期: 2023-09-27 18:34:36
//Splash form:
//------------
frmMain main = new frmMain();
this.Hide();
main.Show();
//MainForm:
//---------
var formToShow = (frmSplash)System.Windows.Forms.Application.OpenForms.Cast<Form>().FirstOrDefault(c => c is frmSplash);
formToShow.Show();
//formToShow.ShowDialog() execute the load event which I dont want.
formToShow.RunTestMetod()
//How I can get the splash hidden form without loading its Load Event and running its //TestMethod(). I want the mainform under it not accessible same like a message box dialog.
我不想要formtoShow.topmost = true,因为它保持在顶部,但第二个表单仍然是可点击的。任何帮助将不胜感激。
您可以将myNewForm.Show(this);
用于要显示为对话框的窗口。这将myNewForm
显示为当前窗体的子窗体,但允许您与当前窗体进行交互。
你可以禁用MainForm吗?
// ...
var formToShow = (frmSplash)System.Windows.Forms.Application.OpenForms.Cast<Form>().FirstOrDefault(c => c is frmSplash);
this.Enabled = false;
formToShow.FormClosed += frm_FormClosed;
formToShow.Show(this);
formToShow.RunTestMetod()
void frm_FormClosed(object sender, FormClosedEventArgs e)
{
this.Enabled = true;
}