using System; using System.Windows.Forms; using System.Threading; class Program { [STAThread] static void Main() { Form f1 = new Form(){ Text = "f1" }; f1.Click += delegate { f1.Close(); Thread t = new Thread(() => { Form f2 = new Form() { Text = "f2" }; //f2.ShowDialog(); Application.Run(f2); }); t.Start(); }; f1.ShowDialog(); } }//经尝试,效果上说好象还行,
Form2 form2=new Form2();
form1.hide();
form2.show();
using System.Windows.Forms;
using System.Threading; class Program {
[STAThread]
static void Main() {
Form f1 = new Form(){ Text = "f1" };
f1.Click += delegate {
f1.Close();
Thread t = new Thread(() => {
Form f2 = new Form() { Text = "f2" };
//f2.ShowDialog();
Application.Run(f2);
});
t.Start();
};
f1.ShowDialog();
}
}//经尝试,效果上说好象还行,
我觉得你怎么说的有点像flash窗体
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); LeftFrameTest frm = new LeftFrameTest();
frm.ShowDialog();
if (frm.bSign)
Application.Run(new Form1());
else
Application.Exit();
}
}//======================================================================
//
// Copyright : SHANGHAI HOMEN INTELLIGENT SYSTEM Co.,LTD.
// All rights reserved
//
// Filename : LeftFrameTest
// Description :
//
// created by 邱在辉 at 2009-12-1 14:17:01
//
//======================================================================using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class LeftFrameTest : Form
{
public bool bSign = false;
public LeftFrameTest()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
this.bSign = true;
this.Close();
}
}
}
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();
this.Close();就可以将上下文的主窗体设置为新的Form2了,然后关闭form1就不影响程序运行了