Move one form to another winforms - C#

谁说我不能喝 提交于 2019-11-30 23:17:20

It sounds a bit like you're trying to create a web-style UI where the user steps from one "page" (represented by a Form) to another.

Rather than implementing a UI like this with separate forms, you're better off doing it with UserControls hosted on a single parent form.

Have a read of this MSDN article, which includes a download with sample code. It's a great walkthrough for designing that kind of user interface:

IUIs and Web-Style Navigation in Windows Forms, Part 1

IUIs and Web-Style Navigation in Windows Forms, Part 2

Edit

If you're intent on showing two separate forms, is there any reason you need to show the second one modally? Can you not simply show it and then hide the original?

form2.Show();
form1.Hide();

... or do you have yet another form that both form1 and form2 are "modal" to?

Subhendu Kumar Behera

To transfer from one page (form1) to another (form2) suppose form1 contain a button named "SAVE" we have to write the following code in click event of the "SAVE" button

form2 f2=new form2();
f2.Show();

I think there is a property on winforms if you would like to show it on the task bar or not.

vishnu

I can clarify your doubt about how to redirect from one form1 to form2

for example: place a link in form1 and then write following code in it

form2 ins=new form2();
ins.show();
Abhishek

Instead of hide use close option.

Form1 formObject = new Form1();
formObject.Close();

or simply

this.Close();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!