1

i implement a wizard in c#, in this manner:

private static void MyInitialization()
{
   WizardData wData = new WizardData();
   wData.FormToShow = WizardData.wizardForms.FirstStep;
   Form step1 = new FirstStep(wData);
   Form step2 = new SecondStep(wData);
   Form step3 = new ThirdStep(wData);
   while (wData.FormToShow != WizardData.wizardForms.Cancel)
   {
     switch (wData.FormToShow)
     {
         case WizardData.wizardForms.FirstStep:
         {
              step1.ShowDialog();
              break;
         }
         case WizardData.wizardForms.SecondStep:
         {
             step2.ShowDialog();
             break;
         }
         case WizardData.wizardForms.ThirdStep:
         {
             step3.ShowDialog();
             break;
          }
      }

when i want to move to another form i need to close the currnet(this.close), but i want make the current visibility=false and not lose the data in the current form when i go to other form?

private void btnNext_Click(object sender, EventArgs e)
{
       // to show the SecondStep form
       wData.FormToShow = WizardData.wizardForms.SecondStep;
       this.Close();
}

any idea?

Shai
  • 25,159
  • 9
  • 44
  • 67
user1082943
  • 33
  • 2
  • 8
  • possible duplicate of [Creating Wizards for Windows Forms in C#](http://stackoverflow.com/questions/2340566/creating-wizards-for-windows-forms-in-c-sharp) – Hans Passant Dec 25 '11 at 13:36

1 Answers1

2

Use the Hide() method

Form1.Hide();

This way, the Form won't be visible, and the data will be saved until you Dispose() of the form.

Shai
  • 25,159
  • 9
  • 44
  • 67