第1个回答 2012-12-28
FrmMain myform = new FrmMain(); //实例
this.Hide(); //隐藏当前
myform.ShowDialog(); //模式显示,这个新窗口不结束语句就停在这
this.Close(); //关闭本回答被网友采纳
第2个回答 2012-12-28
登陆后的页面,用x.showdialog();然后关闭登陆页this.close();
第3个回答 2012-12-28
this.close();把登录窗口关掉。
第4个回答 2012-12-28
例如登录窗体是Form1,主窗体是Form2。
Form2 f2 = new Form2();
f2.Show();
this.Hide();
--------------------------
this.Hide();后任务栏是不会存在登录窗体的,还有就是f2.Show()后不要直接this.Close();因为主窗体f2是从登录窗体Show出来的,如果this.Close();那么登录窗体也会随之关闭!同样,Dispose();也会2个窗体一起关闭!
------------------------
因为如果真的想把this.Close();可以使用下面2种方法:
1.使用新线程和委托
#Thread需要using System.Threading;
Thread t = new Thread(new ThreadStart(delegate { Application.Run(new Form2()); }));
t.Start();
this.Dispose(true);
2.在Program.cs的Main()函数中更改
static void Main()
{
Form1 f1= new Form1();
f1.ShowDialog();
if(f1.DialogResult==DialogResult.OK)
{
Application.Run(new Form2());
}
}
在Form1的登录按钮的Clisk事件中写上:
if(//如果登录成功)
{
this.DialogResult = DialogResult.OK
this.Close();
}
---------------------------------
以上两种方法都能实现this.Close();
但是对于这样的登录来说,this.Hide();就足够的,你说的任务栏还存在窗口?应该是你的编译器的问题吧本回答被提问者采纳