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. Calling a windows form

Calling a windows form

Scheduled Pinned Locked Moved C#
11 Posts 4 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.
  • H Offline
    H Offline
    hosam Taji
    wrote on last edited by
    #1

    Hi every one i have a form name sotred in string parameter i want to create object from that form and show this form thx hosam taji

    S C R 4 Replies Last reply
    0
    • H hosam Taji

      Hi every one i have a form name sotred in string parameter i want to create object from that form and show this form thx hosam taji

      S Offline
      S Offline
      Shoaib Hussain
      wrote on last edited by
      #2

      public Form CreateFormThroughName(string formClassName) { switch(formClassName) { case "FormA": return new FormA(); case "FormB": return new FormB(); } } try it!!!!!

      H 1 Reply Last reply
      0
      • H hosam Taji

        Hi every one i have a form name sotred in string parameter i want to create object from that form and show this form thx hosam taji

        S Offline
        S Offline
        Shoaib Hussain
        wrote on last edited by
        #3

        simply ask thanks if it works

        1 Reply Last reply
        0
        • S Shoaib Hussain

          public Form CreateFormThroughName(string formClassName) { switch(formClassName) { case "FormA": return new FormA(); case "FormB": return new FormB(); } } try it!!!!!

          H Offline
          H Offline
          hosam Taji
          wrote on last edited by
          #4

          First Thx You For Your Help But This is not exactly what i want Realy i want something like this not return new formClassName thx A gain

          C 1 Reply Last reply
          0
          • H hosam Taji

            Hi every one i have a form name sotred in string parameter i want to create object from that form and show this form thx hosam taji

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

            You could use reflection, or if the collection of names is known, use the approach that was given by someone else. Personally, if I had a known collection, I'd be storing an enum, not strings.

            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 )

            H 1 Reply Last reply
            0
            • H hosam Taji

              First Thx You For Your Help But This is not exactly what i want Realy i want something like this not return new formClassName thx A gain

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

              Perhaps you need to explain it better?

              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 )

              S H 2 Replies Last reply
              0
              • C Christian Graus

                Perhaps you need to explain it better?

                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 )

                S Offline
                S Offline
                Shoaib Hussain
                wrote on last edited by
                #7

                do you know the names of all form in advance?

                1 Reply Last reply
                0
                • C Christian Graus

                  Perhaps you need to explain it better?

                  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 )

                  H Offline
                  H Offline
                  hosam Taji
                  wrote on last edited by
                  #8

                  Yes Thats Exactly What I Want How To Use The Refliction in this case Hosam Taji

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    You could use reflection, or if the collection of names is known, use the approach that was given by someone else. Personally, if I had a known collection, I'd be storing an enum, not strings.

                    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 )

                    H Offline
                    H Offline
                    hosam Taji
                    wrote on last edited by
                    #9

                    This The Code Form frm = new Form(); Assembly LocalApp; string man = treeView1.SelectedNode.Name; MessageBox.Show(man); LocalApp = Assembly.LoadFrom(man); ???

                    C 1 Reply Last reply
                    0
                    • H hosam Taji

                      This The Code Form frm = new Form(); Assembly LocalApp; string man = treeView1.SelectedNode.Name; MessageBox.Show(man); LocalApp = Assembly.LoadFrom(man); ???

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

                      hosam Taji wrote:

                      Assembly LocalApp; string man = treeView1.SelectedNode.Name; MessageBox.Show(man); LocalApp = Assembly.LoadFrom(man);

                      I don't know what any of this means ? I mean, what's in the treeview ? Form names, found via reflection ?

                      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
                      • H hosam Taji

                        Hi every one i have a form name sotred in string parameter i want to create object from that form and show this form thx hosam taji

                        R Offline
                        R Offline
                        Ravi Bhavnani
                        wrote on last edited by
                        #11

                        This is off the top of my head and doesn't include any error checking.

                        Assembly asm = System.Reflection.Assembly.LoadFrom ("myAssembly.dll");
                        Type t = asm.GetType ("MyNamespace.MyForm");
                        ConstructorInfo constructor = t.GetConstructor (new Type[] {});
                        MyNamespace.MyForm form = constructor.Invoke (null) as MyNamespace.MyForm;

                        /ravi

                        This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                        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