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. C#
  4. How to open new form

How to open new form

Scheduled Pinned Locked Moved C#
tutorialquestioncareer
6 Posts 5 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
    Areff
    wrote on last edited by
    #1

    I have 2 form in my application 'Form1' & 'Form2' 'Form1' is main form how i can show 'Form2' from 'Form1'? with this code i cant do this job. Form2.ActiveForm.Show();

    N B D 3 Replies Last reply
    0
    • A Areff

      I have 2 form in my application 'Form1' & 'Form2' 'Form1' is main form how i can show 'Form2' from 'Form1'? with this code i cant do this job. Form2.ActiveForm.Show();

      N Offline
      N Offline
      Nicholas Butler
      wrote on last edited by
      #2

      Hi Create an instance of Form2:

      Form2 form2 = new Form2();

      Then, use either:

      form2.Show();

      or

      form2.ShowDialog();

      ---------------------------- Be excellent to each other :) EasiReports[^] My free reporting component for WinForms.

      1 Reply Last reply
      0
      • A Areff

        I have 2 form in my application 'Form1' & 'Form2' 'Form1' is main form how i can show 'Form2' from 'Form1'? with this code i cant do this job. Form2.ActiveForm.Show();

        B Offline
        B Offline
        Brett Slaski
        wrote on last edited by
        #3

        Using some event to call it up (command button, etc.) or just opening in your constructor of form one: System.Windows.Forms.Form form2 = New myNamspace.Form2; Form2.show(); Brettski

        J 1 Reply Last reply
        0
        • B Brett Slaski

          Using some event to call it up (command button, etc.) or just opening in your constructor of form one: System.Windows.Forms.Form form2 = New myNamspace.Form2; Form2.show(); Brettski

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          Seeing as this is a C# forum, that code wont compile like it will in VB.NET I am guilty of the other way round, I always manage to post C# in the VB forum - and it always gets pointed out to me. :-D

          B 1 Reply Last reply
          0
          • A Areff

            I have 2 form in my application 'Form1' & 'Form2' 'Form1' is main form how i can show 'Form2' from 'Form1'? with this code i cant do this job. Form2.ActiveForm.Show();

            D Offline
            D Offline
            Divyang Mithaiwala
            wrote on last edited by
            #5

            Form2 frm = new Form2(); frm.Parent = this; frm.show()


            Divyang Mithaiwala System Engineer & Software Developer

            1 Reply Last reply
            0
            • J J4amieC

              Seeing as this is a C# forum, that code wont compile like it will in VB.NET I am guilty of the other way round, I always manage to post C# in the VB forum - and it always gets pointed out to me. :-D

              B Offline
              B Offline
              Brett Slaski
              wrote on last edited by
              #6

              It wont? Please explain? It's what I use and I don't use vb.net. Thank you, Brett

              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