新建一个项目
在Program.cs文件中一般都是
Application.Run(new frm1());这是我在frm1上加一个按钮并写一个时间让new 一个frm2出来并同时让frm1自动关闭问题出现在实例话frm2并show以后的代码:
this.close();你可以试试,程序fail;我猜想是不是因为frm1本身并没有实例化造成的?因为我把断点设在this.close();上会调试到frm1.designer.cs中的这个函数上
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
在Program.cs文件中一般都是
Application.Run(new frm1());这是我在frm1上加一个按钮并写一个时间让new 一个frm2出来并同时让frm1自动关闭问题出现在实例话frm2并show以后的代码:
this.close();你可以试试,程序fail;我猜想是不是因为frm1本身并没有实例化造成的?因为我把断点设在this.close();上会调试到frm1.designer.cs中的这个函数上
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private System.ComponentModel.Container components = null;
和函数
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
的作用...
虽然朦朦胧胧的知道是干什么的,但是不明确
Application.Run(new frm1());
就已经实例化了一个frm1.......
不过我们老大想了一个更好的方法,
就是把主frm设置成frm2,而只是通过new frm1...
form1做启动窗口,不设主窗口
{
Application.Run(new Form());
this.Close();
}
楼主是不是,向上面这么写的,其实错不再this.Close(),而在Application.Run可以改成
[STAThread]
public static void Main()
{
new Form1().Show();
System.Windows.Forms.Application.Run();
}private void button4_Click(object sender, System.EventArgs e)
{
new Form2().Show();
this.Close();
}
最后退出的时候,别忘了Application.Exit();
private System.ComponentModel.Container components = null;
和函数
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
的作用...
[STAThread]
static void Main()
{
FormLogin fl=new FormLogin();
fl.ShowDialog();
if(fl.DialogResult==DialogResult.OK)
{
FormBookSel fBkSel=new FormBookSel();
fBkSel.ShowDialog();
if(fBkSel.DialogResult==DialogResult.OK)
{
FormRecite fRct=new FormRecite();
Application.Run(fRct);
}
}
}