vs winfrom 界面跳转
在Program类中
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
static class Program
{
internal static ApplicationContext context = new ApplicationContext(new Form1());
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false); 这句要注释掉,否则会出错
Application.Run(context);
}
}
{
internal static ApplicationContext context = new ApplicationContext(new Form1());
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false); 这句要注释掉,否则会出错
Application.Run(context);
}
}
然后这样显示窗体:
Form2 form = new Form2();
Program.context.MainForm = form;
form.Show();
Program.context.MainForm = form;
form.Show();
![](http://www.cnblogs.com/images/cnblogs_com/xsmhero/20091027.jpg)