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. Where to start?

Where to start?

Scheduled Pinned Locked Moved C#
csharpwinformshelptutorialquestion
9 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.
  • F Offline
    F Offline
    FyreWyrm
    wrote on last edited by
    #1

    Ok, I've got this project which I've been developing for about 9 months now as a .NET web application. I was told today that we're switching gears and it's going to be a Windows app instead. Ok, slight problem. I know exactly two things about Windows app development, Jack and S**t. And guess what, Jack's just left town. So I throw myself upon the mercy of the gurus. Can anybody point me to a good tutorial on WinForms that talks about a multi-form application and using menus to switch between active forms. The only WinForm app ever developed by anyone at work was a small demo app that had two forms with a button on form 1 to hide form 1 and show form 2, then a button on form 2 to hide form 2 and show form 1. I've tried googling for some tutorials and I'm coming up with nothing helpful. Anyone got any ideas?

    C D 2 Replies Last reply
    0
    • F FyreWyrm

      Ok, I've got this project which I've been developing for about 9 months now as a .NET web application. I was told today that we're switching gears and it's going to be a Windows app instead. Ok, slight problem. I know exactly two things about Windows app development, Jack and S**t. And guess what, Jack's just left town. So I throw myself upon the mercy of the gurus. Can anybody point me to a good tutorial on WinForms that talks about a multi-form application and using menus to switch between active forms. The only WinForm app ever developed by anyone at work was a small demo app that had two forms with a button on form 1 to hide form 1 and show form 2, then a button on form 2 to hide form 2 and show form 1. I've tried googling for some tutorials and I'm coming up with nothing helpful. Anyone got any ideas?

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

      Well, the main thing is, you just show a form by creating an instance of it and then calling ShowDialog or Show, depending on if you want it to be modal or not. If your main form switches between forms, I'd create them as controls, put them all on the form, and swap which one is visible.

      Christian Graus Please read this if you don't understand the answer I've given you "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 )

      F 1 Reply Last reply
      0
      • C Christian Graus

        Well, the main thing is, you just show a form by creating an instance of it and then calling ShowDialog or Show, depending on if you want it to be modal or not. If your main form switches between forms, I'd create them as controls, put them all on the form, and swap which one is visible.

        Christian Graus Please read this if you don't understand the answer I've given you "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 )

        F Offline
        F Offline
        FyreWyrm
        wrote on last edited by
        #3

        Christian Graus wrote:

        create them as controls, put them all on the form, and swap which one is visible

        That's what the demo app I've got does. But this app is going to be a few hundred forms. It's going to be a replacement for four individual MS Access applications and we're rolling them all into one app as the departments that used them have been consolidated into one. I was hoping to be able to create a menu with some sort of method for showing/hiding controls and when the user clicks on a menu item that control shows and the currently visible one hides. Does that sound reasonable?

        C 1 Reply Last reply
        0
        • F FyreWyrm

          Christian Graus wrote:

          create them as controls, put them all on the form, and swap which one is visible

          That's what the demo app I've got does. But this app is going to be a few hundred forms. It's going to be a replacement for four individual MS Access applications and we're rolling them all into one app as the departments that used them have been consolidated into one. I was hoping to be able to create a menu with some sort of method for showing/hiding controls and when the user clicks on a menu item that control shows and the currently visible one hides. Does that sound reasonable?

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

          FyreWyrm wrote:

          Does that sound reasonable?

          Yeah, the way I'd do that is, have an enum of forms, store the enum for the form you want in the tag, then write a method that you call which hides all forms, then shows the one specified by the enum value. So, you have one menu click event, which reads the tag, then turns it into an enum and calls one method that is always responsible for setting the visible form. You can just iterate over the controls collection to hide your controls. You could even have the controls that are the forms have the same tag values so one function checks each controls tag and works out which one to show, no switch or anything needed.

          Christian Graus Please read this if you don't understand the answer I've given you "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 )

          F 1 Reply Last reply
          0
          • C Christian Graus

            FyreWyrm wrote:

            Does that sound reasonable?

            Yeah, the way I'd do that is, have an enum of forms, store the enum for the form you want in the tag, then write a method that you call which hides all forms, then shows the one specified by the enum value. So, you have one menu click event, which reads the tag, then turns it into an enum and calls one method that is always responsible for setting the visible form. You can just iterate over the controls collection to hide your controls. You could even have the controls that are the forms have the same tag values so one function checks each controls tag and works out which one to show, no switch or anything needed.

            Christian Graus Please read this if you don't understand the answer I've given you "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 )

            F Offline
            F Offline
            FyreWyrm
            wrote on last edited by
            #5

            Thanks Christian. I appreciate your help. I'm going to look into this more when I get to work tomorrow.

            C 1 Reply Last reply
            0
            • F FyreWyrm

              Thanks Christian. I appreciate your help. I'm going to look into this more when I get to work tomorrow.

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

              Cool - just post again if you get stuck.

              Christian Graus Please read this if you don't understand the answer I've given you "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
              • F FyreWyrm

                Ok, I've got this project which I've been developing for about 9 months now as a .NET web application. I was told today that we're switching gears and it's going to be a Windows app instead. Ok, slight problem. I know exactly two things about Windows app development, Jack and S**t. And guess what, Jack's just left town. So I throw myself upon the mercy of the gurus. Can anybody point me to a good tutorial on WinForms that talks about a multi-form application and using menus to switch between active forms. The only WinForm app ever developed by anyone at work was a small demo app that had two forms with a button on form 1 to hide form 1 and show form 2, then a button on form 2 to hide form 2 and show form 1. I've tried googling for some tutorials and I'm coming up with nothing helpful. Anyone got any ideas?

                D Offline
                D Offline
                darkelv
                wrote on last edited by
                #7

                Actually what you need is a WinForm with one main form and every form will be shown in the main form, one at a time, right? You can create the forms as per normal, and instead of calling Show(), do the following instead. The form will be shown in the body of main form.

                Form2 form = new Form2();
                form.FormBorderStyle = FormBorderStyle.None;
                form.TopLevel = false;
                mainForm.Controls.Add(form);
                form.Show();

                C 1 Reply Last reply
                0
                • D darkelv

                  Actually what you need is a WinForm with one main form and every form will be shown in the main form, one at a time, right? You can create the forms as per normal, and instead of calling Show(), do the following instead. The form will be shown in the body of main form.

                  Form2 form = new Form2();
                  form.FormBorderStyle = FormBorderStyle.None;
                  form.TopLevel = false;
                  mainForm.Controls.Add(form);
                  form.Show();

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

                  Cool - so that basically adds the forms as controls, it's another path to what I was saying ?

                  Christian Graus Please read this if you don't understand the answer I've given you "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 )

                  D 1 Reply Last reply
                  0
                  • C Christian Graus

                    Cool - so that basically adds the forms as controls, it's another path to what I was saying ?

                    Christian Graus Please read this if you don't understand the answer I've given you "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 )

                    D Offline
                    D Offline
                    darkelv
                    wrote on last edited by
                    #9

                    Yep, since it's a form as oppose to control, you can change it to MDI easily.

                    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