[英]Starting the same form more than once
我目前有一个项目,其中包含一个名为Panel1的Panel。
由于所有代码都保存在我的控件库中,因此表单中没有类或任何内容。
我可以使用我的4个用户控件中的一个启动表单的单个实例,但是我希望每个控件在不同的窗口中启动,使用相同的Form,与面板。
我已经使用program.cs来允许这个,但每个表单需要在打开下一个之前关闭。
有没有人有任何想法?
这与引用的问题不重复。 当我试图打开1个表单时,但是当前有一个用户控件的不同实例。
使用form.Show()
而不是form.ShowDialog()
不止一次打开表单而不需要关闭它。
试试这个我同时运行两个表格
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var thread = new Thread(ThreadStart);
// allow UI with ApartmentState.STA though [STAThread] above should give that to you
thread.TrySetApartmentState(ApartmentState.STA);
thread.Start();
Application.Run(new Form1());
}
private static void ThreadStart()
{
Application.Run(new Form2());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.