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 Offline
    G Offline
    Gregory Bryant
    wrote on last edited by
    #1

    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

    L P G 3 Replies Last reply
    0
    • 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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Gregory Bryant wrote:

      the first form is hiden using Form1.hide();

      Gregory Bryant wrote:

      open the original first form not a new object

      Form1.Show();

      led mike

      G 1 Reply Last reply
      0
      • L led mike

        Gregory Bryant wrote:

        the first form is hiden using Form1.hide();

        Gregory Bryant wrote:

        open the original first form not a new object

        Form1.Show();

        led mike

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

        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

        L P 2 Replies 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

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Gregory Bryant wrote:

          and i do not know how to get the orginal object from my second form

          that's an Object Oriented Programming beginners issue. You need a C# book for beginners. Trying to learn programming fundamentals over the internet forums is not an efficient means of doing that.

          led mike

          G 1 Reply Last reply
          0
          • 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

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

            I'm going to suggest that you use one of the design patterns here. One that I'm thinking might help is the Mediator pattern (have a look on Google to find it), but it basically looks like this:

            public class Mediator
            {
            private Form1 _loginForm;
            private Form2 _buddyForm;

            public Form2 BuddyForm
            {
            get
            {
            if (_buddyForm == null)
            _buddyForm = new Form2(this);
            return _buddyForm;
            }
            }
            public Form1 LoginForm
            {
            get
            {
            if (_loginForm == null)
            _loginForm = new Form1(this);
            return _loginForm;
            }
            }

            public void Logout()
            {
            LoginForm.Show();
            BuddyForm.Hide();
            }
            // You get the idea for the rest anyway...
            }

            public class Form1 : Form
            {
            private Mediator _mediator;
            public Form1(Mediator mediator)
            {
            _mediator = mediator;
            }

            // Some code to respond to a button for instance
            protected virtual void Login_Click(object sender, EventArgs e)
            {
            _mediator.ShowBuddy();
            }
            }

            public class Form2 : Form
            {
            private Mediator _mediator;
            public Form2(Mediator mediator)
            {
            _mediator = mediator;
            }

            // Some code to respond to a button for instance
            protected virtual void Logout_Click(object sender, EventArgs e)
            {
            _mediator.Logout();
            }
            }

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

            My blog | My articles

            1 Reply Last reply
            0
            • L led mike

              Gregory Bryant wrote:

              and i do not know how to get the orginal object from my second form

              that's an Object Oriented Programming beginners issue. You need a C# book for beginners. Trying to learn programming fundamentals over the internet forums is not an efficient means of doing that.

              led mike

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

              so in other words you dont know thanks lol

              L P P C C 5 Replies Last reply
              0
              • G Gregory Bryant

                so in other words you dont know thanks lol

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                Gregory Bryant wrote:

                so in other words you dont know thanks lol

                Well if I were to decide to insult you in this context it would be because I do know how to do that and have known since about 1992. So what's your reason?

                led mike

                1 Reply Last reply
                0
                • G Gregory Bryant

                  so in other words you dont know thanks lol

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

                  Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.

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

                  My blog | My articles

                  G L 2 Replies Last reply
                  0
                  • P Pete OHanlon

                    Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.

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

                    My blog | My articles

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

                    well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about

                    L P P 3 Replies Last reply
                    0
                    • P Pete OHanlon

                      Do you see that funky shaped icon beside his name? That means he does know - he's just not sure you're capable of this yourself.

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

                      My blog | My articles

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

                      which funky do you mean, AE or BE? if I'm getting insulted, at least let me know and prepare for a fearless riposte. :confused:

                      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
                      • G Gregory Bryant

                        well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about

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

                        I hate to tell you this, but it's a method on the Form class, and does work in C#. I've used it often enough to recognise it.

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

                        My blog | My articles

                        1 Reply Last reply
                        0
                        • G Gregory Bryant

                          well the fuction he is trying to tell me to use is Visual basic function try it your self works fine in VB but not C++ or C# which i was asking about

                          L Offline
                          L Offline
                          led mike
                          wrote on last edited by
                          #12

                          Wrong. I have a C# Windows Forms application that I executed that code in before I posted it to you. I am trying hard not to insult you ( no comments needed from you Pete :-D ), I really mean it sincerely when I suggest you need to use a beginners book. There is nothing wrong with that, I still have shelves of them at home from when I started and I still have to look things up in them almost 20 years later! :laugh: It's a never ending experience learning about development but we really need a foundation to work from.

                          led mike

                          P 1 Reply Last reply
                          0
                          • L Luc Pattyn

                            which funky do you mean, AE or BE? if I'm getting insulted, at least let me know and prepare for a fearless riposte. :confused:

                            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
                            Pete OHanlon
                            wrote on last edited by
                            #13

                            Funky as in classy shaped icon. No insults there - just 3 MVPs chewing the fat.

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

                            My blog | My articles

                            L 1 Reply Last reply
                            0
                            • L led mike

                              Wrong. I have a C# Windows Forms application that I executed that code in before I posted it to you. I am trying hard not to insult you ( no comments needed from you Pete :-D ), I really mean it sincerely when I suggest you need to use a beginners book. There is nothing wrong with that, I still have shelves of them at home from when I started and I still have to look things up in them almost 20 years later! :laugh: It's a never ending experience learning about development but we really need a foundation to work from.

                              led mike

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

                              led mike wrote:

                              I am trying hard not to insult you ( no comments needed from you Pete ),

                              Moi? Little ole moi? Would I...?

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

                              My blog | My articles

                              1 Reply Last reply
                              0
                              • P Pete OHanlon

                                Funky as in classy shaped icon. No insults there - just 3 MVPs chewing the fat.

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

                                My blog | My articles

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

                                Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)

                                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.


                                L P 2 Replies Last reply
                                0
                                • L Luc Pattyn

                                  Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)

                                  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.


                                  L Offline
                                  L Offline
                                  led mike
                                  wrote on last edited by
                                  #16

                                  Luc Pattyn wrote:

                                  did/does CP ever explain what MVP stands for?

                                  I don't know about yours but my award stands for Most Valuable Puke. I wanted Most Valuable Cookie Tosser but Chris said John Simmons already had that.

                                  led mike

                                  L 1 Reply Last reply
                                  0
                                  • L Luc Pattyn

                                    Which leads to another question: did/does CP ever explain what MVP stands for? it could be many things, Most Vertical Primate being one of them. :)

                                    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
                                    Pete OHanlon
                                    wrote on last edited by
                                    #17

                                    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

                                    L E 2 Replies Last reply
                                    0
                                    • L led mike

                                      Luc Pattyn wrote:

                                      did/does CP ever explain what MVP stands for?

                                      I don't know about yours but my award stands for Most Valuable Puke. I wanted Most Valuable Cookie Tosser but Chris said John Simmons already had that.

                                      led mike

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

                                      it seems to me we need another editable column in the database, so we can personalize this. And in a couple of weeks the friday quiz question: given 40 MVP names and 40 titles, who is who? :)

                                      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.


                                      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

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

                                        I didn't see you as a pessimist :doh:

                                        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.


                                        1 Reply Last reply
                                        0
                                        • G Gregory Bryant

                                          so in other words you dont know thanks lol

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

                                          No. He is telling you to get a book and learn.

                                          "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - 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