Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to show/hide forms ?

how to show/hide forms ?

Scheduled Pinned Locked Moved C#
questiontutorial
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashraf zia
    wrote on last edited by
    #1

    I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

    P R H Q S 5 Replies Last reply
    0
    • A Ashraf zia

      I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Errm - create the new form and show it, then set the .Visible to false on the current one?

      Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world." Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that." Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      • A Ashraf zia

        I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

        R Offline
        R Offline
        Rahithi
        wrote on last edited by
        #3

        hi u need to write this code in Button click event. this.Close(); requiredForm.Show(); regards, Rahi

        A 1 Reply Last reply
        0
        • R Rahithi

          hi u need to write this code in Button click event. this.Close(); requiredForm.Show(); regards, Rahi

          A Offline
          A Offline
          Ashraf zia
          wrote on last edited by
          #4

          I have done this but still no result. I am currently in index.cs file and want to access StudentArea.cs. Beside Student_Area button code in index.cs file i have wrote the code according to your method and get the following error. "C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\online_exam_csharp\index.cs(119): An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' "

          R 1 Reply Last reply
          0
          • A Ashraf zia

            I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

            H Offline
            H Offline
            Haseeb Mukhtar
            wrote on last edited by
            #5

            Hello Ashraf, Suppose you have 1 MDI Parent form which is "MAIN" and two mdi child forms which are "child1" and "child2" In form child1 there is a button for opening child2 form and close child1 form, try this code child2 objchild2=new child2(); this.hide(); objchild2.show();

            1 Reply Last reply
            0
            • A Ashraf zia

              I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

              Q Offline
              Q Offline
              quiteSmart
              wrote on last edited by
              #6

              hi, You can do this by just overriding the constructor of the form that you want to open the last. In overriding the constructor put in it as an argument an instance of type first form (the one that contains the botton). For example, let us say that the last form to open is lastForm and the first one is firstForm. You write the constructor of lastForm as follows: public viod lastForm( firstForm first ) { InitialyseComponent(); first.dispose(); } and when calling the last form through the botton, you initialyze a new form and give it as an argument a reference to the current form: private void button1_click( sender object, e ) { lastForm last = new lastForm(this); last.show(); } hope it helps Jamil Abou Khalil

              1 Reply Last reply
              0
              • A Ashraf zia

                I have created MDI Form. Now inside the Child Form i have button and when the button is clicked i want to display another form and hide the current one. How can i do this ???:confused:

                S Offline
                S Offline
                shaz jazz
                wrote on last edited by
                #7

                you have to put following code behind the button against which you want to... this.hide(); NewForm nw = new NewForm(); nw.ShowDialog(); nw.Activate(); nw.Close(); it is a well experienced code and u should not face any problems.hope your question is answered! regards

                ShaZ JazZ

                1 Reply Last reply
                0
                • A Ashraf zia

                  I have done this but still no result. I am currently in index.cs file and want to access StudentArea.cs. Beside Student_Area button code in index.cs file i have wrote the code according to your method and get the following error. "C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\online_exam_csharp\index.cs(119): An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' "

                  R Offline
                  R Offline
                  Rahithi
                  wrote on last edited by
                  #8

                  hi, can u send me the exercise what exactly do u want to code? is it correct: just u have 2 forms page1 and page2 u have one button on page1. when u click on button, the control should move to page2 and page1 should be unloaded. if not, please try to send me the problem, so that i can write the code and send it to u. Regards, Rahi

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups