how to go to previous form inC#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subrat kumarnayak
    New Member
    • Jul 2010
    • 10

    how to go to previous form inC#.net

    i m in a frm and i want to its previous frm
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    Originally posted by subrat kumarnayak
    i m in a frm and i want to its previous frm
    How did you reach there...
    did you draw yourself on the form using GDI+..


    Plz specify more details about your problem...

    Comment

    • maddyromeo
      New Member
      • Jul 2010
      • 22

      #3
      assuming 2 forms : Form1 and Form2

      to move from Form2 to previous Form1:
      Code:
      //code in Form1
      Form2 f2 = new Form2(this);
      this.Hide();
      f2.Show();
      
      //code in Form2
      Form f1;               //global member
      public Form2(Form1 f1) //constructor
      {
      InitializeComponents();
      this.f1 = f1;
      }
      
      button_Click(o s,ea e) 
      {
      this.Close();
      f1.Show();
      }
      Last edited by MMcCarthy; Aug 4 '10, 05:29 AM. Reason: Added code tags

      Comment

      • Joseph Martell
        Recognized Expert New Member
        • Jan 2010
        • 198

        #4
        You could show form 2 using ShowDialog() instead of Show(). This would bring execution back to form 1 after form 2 has closed.

        Comment

        Working...