因此,我有一個本身是控制檯應用程序但管理幾種表單的程序。主要形式有能力發佈輔助表單,我希望它能夠發佈多個輔助表單。如何保存我在屏幕上使用.Show()方法啓動的表單
問題是,當我使用模態命令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()的所有下列窗體,並且這似乎正在工作對我來說
是不是很常見?當你啓動一個對話框時,你不應該導航到另一個同樣的解決方案?對不起,如果我誤解了你的問題:/ – sora0419
上下文位:我有一個模擬OS GUI的項目。輔助表單是操作系統中的「程序」(到目前爲止只是一個文本編輯器)。我希望能夠一次打開多個「程序」 – JeffL