博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

winform登录后跳转 (主窗体转移到新窗口)

Posted on 2010-01-13 14:43  heeeey  阅读(1775)  评论(0)    收藏  举报

在Program类中

 

代码
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);   
}   
}  

 

然后这样显示窗体:

Form2 form = new Form2();   
Program.context.MainForm 
= form;   
form.Show();  

 

就可以将上下文的主窗体设置为新的Form2了,然后关闭form1就不影响程序运行了