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. C# calling forms

C# calling forms

Scheduled Pinned Locked Moved Windows Forms
csharphelp
38 Posts 9 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.
  • G Gregory Bryant

    in c# i created the first form as a login the second displays a buddy list once you login the first form is hiden using Form1.hide(); now on the second one i have a log out button that i want to close the second form and open the original first form not a new object i have everything done but reopening the first form. thank you if you can help

    G Offline
    G Offline
    Gregory Bryant
    wrote on last edited by
    #23

    Since you couldnt help here is how you do it declare a public, static variable of type Form1 just below the Form1 class declaration. I’ve named the variable frm1 public static Form1 frm1 = null; then when you show form2 frm1 = this; this.Visible = false; Form2 frm2 = new Form2(); frm2.Show(); then from form2 you can call Form1.frm1.show(); so thanks for all your help lol

    P C P 3 Replies Last reply
    0
    • C Colin Angus Mackay

      Gregory Bryant wrote:

      so in other words you dont know

      Look at the icon, man! He's an MVP, dude!

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #24

      Another one. What happened to the normal people? They are supposed to run in the millions. :-D

      Luc Pattyn [Forum Guidelines] [My Articles]


      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


      P 1 Reply Last reply
      0
      • L Luc Pattyn

        Another one. What happened to the normal people? They are supposed to run in the millions. :-D

        Luc Pattyn [Forum Guidelines] [My Articles]


        This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #25

        Luc Pattyn wrote:

        What happened to the normal people?

        Ahem, I've barked at the OP a few times :rolleyes:

        "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

        L P 2 Replies Last reply
        0
        • P Paul Conrad

          Luc Pattyn wrote:

          What happened to the normal people?

          Ahem, I've barked at the OP a few times :rolleyes:

          "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #26

          Sorry, I forgot about your daily show... :laugh:

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          P 1 Reply Last reply
          0
          • L Luc Pattyn

            Sorry, I forgot about your daily show... :laugh:

            Luc Pattyn [Forum Guidelines] [My Articles]


            This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #27

            It's okay :laugh:

            "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

            1 Reply Last reply
            0
            • G Gregory Bryant

              Since you couldnt help here is how you do it declare a public, static variable of type Form1 just below the Form1 class declaration. I’ve named the variable frm1 public static Form1 frm1 = null; then when you show form2 frm1 = this; this.Visible = false; Form2 frm2 = new Form2(); frm2.Show(); then from form2 you can call Form1.frm1.show(); so thanks for all your help lol

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #28

              http://www.codeproject.com/KB/dotnet/passingvaluesbetweenforms.aspx[^] by Colin Mackay could be helpful for you :)

              "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

              1 Reply Last reply
              0
              • G Gregory Bryant

                i am trying to open the first form from the second that does not work i get an error An object reference is required but i dont want to creat a new object and i do not know how to get the orginal object from my second form

                P Offline
                P Offline
                PRACTICE
                wrote on last edited by
                #29

                in form2 form1 f1 = new form1() f1.show() try this.

                C 1 Reply Last reply
                0
                • G Gregory Bryant

                  so in other words you dont know thanks lol

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

                  No, in other words, you plainly have no idea what you're doing and should learn some basics before wasting all our time asking questions you don't understand the answer to.

                  Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  1 Reply Last reply
                  0
                  • G Gregory Bryant

                    Since you couldnt help here is how you do it declare a public, static variable of type Form1 just below the Form1 class declaration. I’ve named the variable frm1 public static Form1 frm1 = null; then when you show form2 frm1 = this; this.Visible = false; Form2 frm2 = new Form2(); frm2.Show(); then from form2 you can call Form1.frm1.show(); so thanks for all your help lol

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

                    Wow - that's some nasty ass code. Can I make a few suggestions: 1 - buy a beginners book before you become more entrenched in the really bad habits that you're currently forming. Otherwise, your code will always suck as much as this code does. 2 - try to use real variable names. form1 and form2 make sense on your first day of coding, they are not workable in a real project Seriously, you come here, ask for help, complain when you get it, and then you're all proud because you found a way that frankly, belongs in the coding horrors forum.

                    Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                    1 Reply Last reply
                    0
                    • G Gregory Bryant

                      Since you couldnt help here is how you do it declare a public, static variable of type Form1 just below the Form1 class declaration. I’ve named the variable frm1 public static Form1 frm1 = null; then when you show form2 frm1 = this; this.Visible = false; Form2 frm2 = new Form2(); frm2.Show(); then from form2 you can call Form1.frm1.show(); so thanks for all your help lol

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

                      That's one seriously bad piece of code. Why do you think yours is better than the solution I posted above? Let's see - I've been in this industry over 20 years, and have extensive experience in developing applications including using patterns to develop robust systems - and you? Well you accept default form names. Nuff said.

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles

                      C 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        I'd like to think it's Most Valuable Professional, but in my case it could be Madly Vocal Pessimist.

                        Deja View - the feeling that you've seen this post before.

                        My blog | My articles

                        E Offline
                        E Offline
                        El Corazon
                        wrote on last edited by
                        #33

                        Pete O'Hanlon wrote:

                        but in my case it could be Madly Vocal Pessimist.

                        If the award was for that, it would be much easier for me to win one. In fact I would probably have top honors. ;P

                        _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                        1 Reply Last reply
                        0
                        • P PRACTICE

                          in form2 form1 f1 = new form1() f1.show() try this.

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

                          That's also pretty bad.

                          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                          1 Reply Last reply
                          0
                          • P Pete OHanlon

                            That's one seriously bad piece of code. Why do you think yours is better than the solution I posted above? Let's see - I've been in this industry over 20 years, and have extensive experience in developing applications including using patterns to develop robust systems - and you? Well you accept default form names. Nuff said.

                            Deja View - the feeling that you've seen this post before.

                            My blog | My articles

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

                            But look how much code yours is. His is three lines or something, so it MUST be better.....

                            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                            P 1 Reply Last reply
                            0
                            • C Christian Graus

                              But look how much code yours is. His is three lines or something, so it MUST be better.....

                              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

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

                              Thanks for that - that really made me laugh, and I needed it. :laugh:

                              Deja View - the feeling that you've seen this post before.

                              My blog | My articles

                              1 Reply Last reply
                              0
                              • P Paul Conrad

                                Luc Pattyn wrote:

                                What happened to the normal people?

                                Ahem, I've barked at the OP a few times :rolleyes:

                                "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

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

                                Don't worry - I've no doubt that you'll be joining the hallowed ranks soon enough.

                                Deja View - the feeling that you've seen this post before.

                                My blog | My articles

                                P 1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  Don't worry - I've no doubt that you'll be joining the hallowed ranks soon enough.

                                  Deja View - the feeling that you've seen this post before.

                                  My blog | My articles

                                  P Offline
                                  P Offline
                                  Paul Conrad
                                  wrote on last edited by
                                  #38

                                  I pretty sure someday :-D Just need to get off my butt and write some articles :-\

                                  "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

                                  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