Windows应用程序中的表单重定向
好吧,我是Windows窗体应用程序的新手,我创建了一个接受值并将其提交到db的窗体,但是在单击按钮时,我需要关闭当前窗体并重定向到另一个窗体,该怎么做.感谢您的帮助.祝您有个美好的一天
ok im a newbie to windows form application, ive created a form which takes in values and submits it into a db but on button click i need to close the current form an redirect to another form, how can this be done. Thanks for ur help. Have a good day cheers
使用此代码.
Use this code.
Form2 f = new Form2();
this.Hide();
f.Show();
您可以在按钮单击事件上使用此代码.
You can use this code on your button click event.
Form2 fm2 = new Form2();
fm2.ShowDialog();
这将打开一个Form2作为新窗口.但是,如果您要关闭电流并打开一个新的电流,则必须使用MDIParent和MDIChild组合
http://msdn.microsoft.com/en-us/library/7aw8zc76 (v = vs.80).aspx [
this will open a Form2 as new window. but if u want to close current and to open a new one, then you have to use MDIParent and MDIChild combination
http://msdn.microsoft.com/en-us/library/7aw8zc76(v=vs.80).aspx[^]
use
fm2.Show();
如果form2是MDIChild.
希望对您有所帮助.
if form2 is MDIChild.
Hop this helps..
单击按钮添加此
Form1 newForm = new Form1();//Form1是您要打开的表单的名称
newForm.show();
this.close();
on button click add this
Form1 newForm=new Form1();// Form1 is name of your form that u want to open
newForm.show();
this.close();