Handle multiple windows forms in a windows application

Hi,

I'm new to Windows Forms.

Let say I have 2 forms, Form A and Form B.
@ Form A, there is a datagrid and a image displayed.
if I clicked a OK button on Form A, it should replaced by Form B.
but not 2 windows forms.

It will be good if there are any examples in C#.

Thanks.
Buru.



Answer this question

Handle multiple windows forms in a windows application

  • Jack Hudler

    Hi Paul,

    I tried your method. However, it gives me a compilation error "No overload for method 'Show' takes '1' arguments".

    Pls advice.

    Thanks.
    Buru.

  • ShreyN

    Hi,

    I guess your using VS2003. In VS2005 you could call the show method without any parameters. In 2003 you could do it this way.

    owner.show(this);

     

     

     

    cheers,

    Paul June A. Domag



  • farmer101

    Hi,

    Basically you could just use the show and hide methods of the forms. You must also set the parent property to the form. Here's a sample:

    On your Form A:

      private void button1_Click(object sender, EventArgs e) {
       Form2 otherForm = new Form2();
       this.Hide();
       otherForm.Show(this);
      }

    On your Form B:

      private void button1_Click(object sender, EventArgs e) {
       Owner.Show();
       this.Hide();
      }
     }

     

    cheers,

    Paul June A. Domag



  • Handle multiple windows forms in a windows application