Changing form on submit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amrhosam
    New Member
    • Feb 2010
    • 5

    Changing form on submit

    hello everyone,
    i am new here and i am also a new programmer and i am learning c#..i am using visual studio 2008 and started to build some very simple windows form apllication and now i am facing a problem.
    how can i open a new form to replace the old form in a way such that when i close the second form ..all of the application gets terminated..som ething like the installation wizard of a program or a game..when you hit the next button the window form changes completely and whenver i press the (x)button on top right the installation wizard terminates completelly..i hope someone helps me as i really need to learn that so i can keep going

    i hope i can find the help i need here..thanks all in advance
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    My suggestion is to not use multiple forms.
    Use one form.
    Put a panel on it: Dock set to full.
    Then keep putting new UserControls on the dock.
    That way you can flip through 'screens' one UserControl at a time, then exit when you are done.

    Also "I need help" is hardly an informative title. What if all 1,000 posts a day said that?
    Please visit the Posting Guidelines for tips on how to ask questions to get the best help.

    Comment

    • ThatThatGuy
      Recognized Expert Contributor
      • Jul 2009
      • 453

      #3
      On the second form on the Forms FormClosing Event type
      this.Hide() or this.Close()...
      will hide the second form ... and will not terminate the whole application

      Comment

      • amrhosam
        New Member
        • Feb 2010
        • 5

        #4
        @tlhintoq
        first of all thank you so much for your help an i alos apologize for notreading the ruels of postin a question..it was so late(3 am)and i was so tired and hardly opened my eyes..programmi ng learning is harder that i thought,

        i was hoping you can tell me what do you mean by : (Put a panel on it: Dock set to full)
        i am new to c# and only started learing it like 7 days ago..i still have to figure this one out b4 i move on to learning about XML files and i also hope you will help me with that if i needed help and don't worry..the next time ,i will write an appropriate title for my thread.

        @ThatThatGuy

        thanks alot for your help..you gave me a great first impression about his forum and i am hoping to continue with you guys here and hopefully be a good programmer someday..thanks alot for your help

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          i was hoping you can tell me what do you mean by : (Put a panel on it: Dock set to full)
          Sure. It doesn't really have to be done this way... I just find it easy to use the panel as a reference.

          You have a form, probably named "Form1" by Visual studio...
          From the Toolbox, drag a "FlowLayoutPane l" to the form. Visual Studio will name it FlowLayoutPanel 1.
          Go to the Properties pallet.
          Set AutoScroll to true.
          Set Dock to fill
          Go back to the form designer. Right-click on the form. Choose "View Code". It should look similar to this:
          Code:
          namespace DemoPOS
          {
              public partial class Form1 : Form
              {
                  public Form1()
                  {
                      InitializeComponent();
                  }
              }
          }
          Add the new code shown:
          Code:
          namespace DemoPOS
          {
              public partial class Form1 : Form
              {
                  public Form1()
                  {
                      InitializeComponent();
                  }
          
             [I][B]     Control.ControlCollection WorkZone
                  {
                      get
                      {
                          return flowLayoutPanel1.Controls;
                      }
                  }
              }[/B][/I]
          }
          This is a read-only property (because it only has a 'get' method and no 'set' method, that will return all the controls in the FlowLayouPanel you just dropped on the form. This makes for a more convenient reference in your code later.

          Now make all those different 'Wizard-like' steps that you need. Make each one as a UserControl instead of as a form.

          Add and remove controls from the WorkZone as needed.
          Code:
                  public void Step2()
                  {
                      ucStageTwo myStepTwo = new ucStageTwo();//ucStageTwo is the user control you made to be your second Wizard page
                      WorkZone.Clear();
                      WorkZone.Add(myStepTwo);
                  }

          Comment

          • amrhosam
            New Member
            • Feb 2010
            • 5

            #6
            @tlhintoq

            thanks alot ..i really really appretiate your help..thanks so much...i will try the solution you suggested and tell you the result asap..
            thank you again and i am so glad that i subscribed on this great forum,.

            Comment

            • amrhosam
              New Member
              • Feb 2010
              • 5

              #7
              @tlhintoq


              i tried as u said ...and i didn't get the result i am looking for..i knw i may be a pain in the ass but i really want to learn...i hope if you can give me a full example of simple two pages wizard..the first one with a button on it called next and the second one(panel) is the one which appears when i click the next button..i hope you give me a detailed program code for it..so i can completelyy understand how it is done and start working on my dsired function...i apologize again for asking too much..thanks and i hope you continue helping me and don't give up on me

              Comment

              • Bassem
                Contributor
                • Dec 2008
                • 344

                #8
                On the second form on the Forms FormClosing Event type
                this.Hide() or this.Close()...
                will hide the second form ... and will not terminate the whole application
                I don't think so.

                The event fire while the Form is closing. So, hiding the form closing the from will not make a change, after all the form is closed.

                Thanks,
                Bassem

                Comment

                Working...