[英]How to show multiple forms simultaneously
I know this may have been answered, but I just can't find a suitable answer. 我知道可能已经回答了,但是我找不到合适的答案。 Any idea how to show more than one Windows Form? 知道如何显示多个Windows窗体吗?
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
Application.Run(new MenuModule());
}
By declaring two Application.Run
, the the Windows Form will show after I exit the first. 通过声明两个Application.Run
,我退出第一个窗口后将显示Windows窗体。
When you use that overload of Application.Run
it will block until the form you passed has closed. 当您使用Application.Run
重载时,它将一直阻塞,直到关闭您传递的表单为止。
You could try: 您可以尝试:
new Main().Show();
new MenuModule().Show();
Application.Run();
This will run until you call Application.Exit
even if both forms have been closed. 这将一直运行,直到您调用Application.Exit
即使两个窗体都已关闭。 So a better option might be: 因此,更好的选择可能是:
new MenuModule().Show();
Application.Run( new Main() );
Which will cause the application to exit after the Main
form has closed, regardless of the status of the MenuModule
form. 不管MenuModule
窗体的状态如何,这都会导致应用程序在Main
窗体关闭后退出。
As an option you could also have the Main
form show the second one, that'll work too. 作为一种选择,您还可以让Main
表单显示第二个表单,它也将起作用。
you can create an object in 'Main' class (form) contractor. 您可以在“主要”类(表单)承包商中创建一个对象。
public main(){
.
.
.
new MenuModule().show();
.
.
.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.