所以我有一个程序,它本身就是一个控制台应用程序,但它管理着一些表单。主窗体能够启动辅助窗体,我希望它能够启动多个辅助窗体。
问题是当我使用模态命令时Form.ShowDialog()
,我无法离开辅助窗体并访问主窗体,因此我无法启动第二个辅助窗体。
我遇到的麻烦Form.Show()
是,一旦表单启动,它就会再次关闭。当然,它运行初始函数,但随后立即消失。处理这种无模式显示但保留表单的最佳方法是什么?
编辑:这是我正在使用的格式。我有一个自定义的 Process 类来处理表单,每个进程都存储在控制台应用程序的列表中,每个进程都有自己的 myFORM
public class Process
{
/*The process class is used to track all running processes related to GeFoss(any forms or consol apps, etc)
* Methods:
* -initialize: This has two overloads, one for a form, and one for general objects. Basically this just starts the main part of the app
* -ShowDialog: This simply calls the Form.ShowDialog method if the process controls a Form
* -_NewThread: Begins a new thread centered on Leo
* -Leo: simply launches another copy of the same Object
*/
public Form myFORM;
public Type mytype;
.
.
.
.
.
. .
.
.
public void ShowDialog()
{
//This should only be called when the type of Process is a form. If it isn't a form though, the try-catch will prevent a crash
try
{
myFORM.Show();
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex));
}
}\
\
编辑:我能够找到解决方法。由于我正在处理的项目有点像模拟操作系统,我告诉它使用 Form.ShowDialog() 启动主 GUI 表单,并使用 Form.Show() 启动以下所有表单,这似乎正在工作为了我