gpt4 book ai didi

C# "Form that is already visible cannot be displayed as a modal dialog box. Set the form' 的可见属性在调用 showDialog 之前设置为 false。”

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:19 26 4
gpt4 key购买 nike

这是我在表单中的代码。这个函数应该打开另一个我作为对话框创建的表单,但我一直收到错误:

Form that is already visible cannot be displayed as a modal dialog box. Set the form's visible property to false before calling showDialog.

我查看了所有表单属性,但无法在任何地方找到它。我错过了什么?使用 Visual Studio 2015 和带有 .net 4 的 winforms 应用程序

    private void disconnect_Click(object sender, EventArgs e)
{
ShowDialog(new ManagerWarning());
}

最佳答案

您实际上是在尝试调用当前 View 的 ShowDialog 方法,将 new ManagerWarning() 作为参数(实际上,尝试将当前 View 作为模态,以新形式作为父形式)。

创建窗体 ManagerWarning 的实例并尝试以这种方式运行

private void disconnect_Click(object sender, EventArgs e)
{
ManagerWarning m = new ManagerWarning();
m.ShowDialog();
}

关于C# "Form that is already visible cannot be displayed as a modal dialog box. Set the form' 的可见属性在调用 showDialog 之前设置为 false。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38727663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com