有三个方法:
其一:
[STAThread]
static void Main()
{
Form1 newForm1 = new Form1();
newForm1.ShowDialog();
}其二:
[STAThread]
static void Main()
{
Form1 newForm1 = new Form1();
Application.Run(newForm1)
}
其三:
[STAThread]
static void Main()
{
Application.Run(new newForm1())
}
其一:
[STAThread]
static void Main()
{
Form1 newForm1 = new Form1();
newForm1.ShowDialog();
}其二:
[STAThread]
static void Main()
{
Form1 newForm1 = new Form1();
Application.Run(newForm1)
}
其三:
[STAThread]
static void Main()
{
Application.Run(new newForm1())
}
using System;
using System.Forms;......Static void Main()
{
Form1 newForm1 = new Form1();
Application.Run(newForm1);
}
或者用Application.Run()这个方法,用这个方法的时候相当于是一个循环程序也会一直到你的窗体关掉才会向下运行到退出.
谢谢!你的方法我用过,是正确的。不过如上面的代码,如果是用Application.Run方法,要先引用System.Forms。
再请教,是否有从非窗体文件中实例化并显示一个窗体,都不能直接用Show()方法,而必须要用ShowDialog()或Application.Run()?
呵呵,谢谢!你上面的话已经回答了我的上面的问题,不过刚才没看到:)