-3

I have created the multiple windows form in C#.For EX. We have two forms and we have next button in Form1 and previous button in Form2 . But when we try to go form Form2 to Form1 using previous button Form2 is not closing and Form1 is appearing on Form2. To show forms we are using ShowDialog. So how can we create the form one linked to another as pages.

Fazal
  • 39
  • 6
  • Can you give your code – Rashid Dec 09 '16 at 05:08
  • This is called Wizard. You might try [this answer](http://stackoverflow.com/a/2342320/529282) or grab any third party wizard control for WinForm – Martheen Dec 09 '16 at 05:09
  • `this.Hide(); form1.Show();` also please consider above comments. – Keppy Dec 09 '16 at 05:18
  • 1
    Possible duplicate of [Creating Wizards for Windows Forms in C#](http://stackoverflow.com/questions/2340566/creating-wizards-for-windows-forms-in-c-sharp) – BJ Myers Dec 09 '16 at 05:37

2 Answers2

0

It looks like you're trying to implement a "wizard" in your application.

The more typical approach is to have each "page" as a control/user control and load the appropriate step in the same dialog as the user moves along.

You may benefit from looking at some examples leveraging existing libraries to make this simpler. One example is here: https://www.codeproject.com/articles/120607/simple-wizard-for-winforms

This answer also covers this topic and provides a few more resources: Which wizard control can I use in a WinForms application?

Community
  • 1
  • 1
Fabio Cavalcante
  • 12,328
  • 3
  • 35
  • 43
0

What you can do is like this:

In form1's button handler,

form2 f2=new form2();
f2.show();
this.hide();

And in Form2's button handler,

form1 f1=new form1();
f1.show();
this.hide();

But make sure you write proper code in close button handler as the forms are just hidden. Not closed.

ip31
  • 1