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
  1. Home
  2. General Programming
  3. Windows Forms
  4. Form1 to Form2

Form1 to Form2

Scheduled Pinned Locked Moved Windows Forms
csharpwinformstutorial
4 Posts 3 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.
  • M Offline
    M Offline
    madhurialuru
    wrote on last edited by
    #1

    Hai I am new to WinForms how to close Form1 when I moved to Form2 in a button click...

    try until u succeed

    R C 2 Replies Last reply
    0
    • M madhurialuru

      Hai I am new to WinForms how to close Form1 when I moved to Form2 in a button click...

      try until u succeed

      R Offline
      R Offline
      Rahul83
      wrote on last edited by
      #2

      at the buttin click event create an instance of current form and the form u want open..try sumthing like this At button click event: currentform form1=new currentform(); formToOpen form2=new formToOpen(); form1.hide(); form2.show(); bye

      C 1 Reply Last reply
      0
      • R Rahul83

        at the buttin click event create an instance of current form and the form u want open..try sumthing like this At button click event: currentform form1=new currentform(); formToOpen form2=new formToOpen(); form1.hide(); form2.show(); bye

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Rahul83 wrote:

        currentform form1=new currentform();

        I'm sorry, but that plain will not work. It creates a new Form1, which will have no bearing on the one that is visible.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • M madhurialuru

          Hai I am new to WinForms how to close Form1 when I moved to Form2 in a button click...

          try until u succeed

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You can call Hide() to hide the visible form, and then show form2 using ShowDialog() if you want a modal form ( I presume you do, why would you want a modeless form attached to an invisible form ? ) A better approach is to define both forms as user controls and put them on the one form, and just swap which one is visible.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          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