原来的form是父窗体不能关闭,只能隐藏。
在form1的按钮事件里写
Form2 ftm2 = new Form2();
ftm2.show();
me.visable = false;
我在Program.cs做的这个操作,让Form2作为程序主窗体。
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form1= new Form1 ();
form1.Show();
if (加一个判断条件)
{
Application.Run(new Form2());
}
}
private void button2_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.SetParent(this);
form2.ShowDialog();
}
你可以把form1上的用close关闭试试,要是不行就按楼上的做吧
同意楼上说法
一般做法都是楼上的visable=false