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. Windows Form

Windows Form

Scheduled Pinned Locked Moved Windows Forms
csharptutorial
7 Posts 4 Posters 2 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.
  • D Offline
    D Offline
    DSPNEOqqq
    wrote on last edited by
    #1

    How to create parent form and child form usin c#. I want to create a parent form and two or three radio buttons should be on parent form, when user click on 1st radio button then a child form should be opened related to 1st radio button and another radio button vice-versa....... Please reply Quickly.........

    DSPNEO

    L C B 3 Replies Last reply
    0
    • D DSPNEOqqq

      How to create parent form and child form usin c#. I want to create a parent form and two or three radio buttons should be on parent form, when user click on 1st radio button then a child form should be opened related to 1st radio button and another radio button vice-versa....... Please reply Quickly.........

      DSPNEO

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Put a button on there, doubleclick;

      public void Form1_Button1_Click(object sender, EventArgs e)
      {
      using(var myForm = new FormChildWithCoolName())
      {
      myForm.ShowDialog(this);
      }
      }

      DSPNEOqqq wrote:

      Please reply Quickly.........

      Quickly, quickly Zathras..

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      L 1 Reply Last reply
      0
      • L Lost User

        Put a button on there, doubleclick;

        public void Form1_Button1_Click(object sender, EventArgs e)
        {
        using(var myForm = new FormChildWithCoolName())
        {
        myForm.ShowDialog(this);
        }
        }

        DSPNEOqqq wrote:

        Please reply Quickly.........

        Quickly, quickly Zathras..

        Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Eddy Vluggen wrote:

        Quickly, quickly Zathras..

        Babylon 5?

        Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

        L 1 Reply Last reply
        0
        • L Lost User

          Eddy Vluggen wrote:

          Quickly, quickly Zathras..

          Babylon 5?

          Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yup :)

          1 Reply Last reply
          0
          • D DSPNEOqqq

            How to create parent form and child form usin c#. I want to create a parent form and two or three radio buttons should be on parent form, when user click on 1st radio button then a child form should be opened related to 1st radio button and another radio button vice-versa....... Please reply Quickly.........

            DSPNEO

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

            Create your forms, set the parent form as Owner of the child. May be MDI forms can helps too. That's all.

            Christian Amado MCITP | MCTS | MOS | MTA Olimpia ☆ ★★★ Please mark as answer, if it helps.

            1 Reply Last reply
            0
            • D DSPNEOqqq

              How to create parent form and child form usin c#. I want to create a parent form and two or three radio buttons should be on parent form, when user click on 1st radio button then a child form should be opened related to 1st radio button and another radio button vice-versa....... Please reply Quickly.........

              DSPNEO

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #6

              Hi, First, I believe that Child Forms should never be used, that they lead to awkward user-interfaces, and the old MDI-architecture, which supported MDIChildForms with "special features," deserves the status of a "dinosaur" skeleton: to be looked at, but not re-animated :) I think you can get better responses to this scenario if you describe what the function of your proposed use of "Child Forms" are, in relation to their "Parent" Form. Is it possible a Dialog can fit your needs here ? Consider that you create a "Child Form" with code like this in response to some event:

                      Form form2 = new Form();
                      form2.TopLevel = false; // mandatory for Child Forms
                      form2.ShowInTaskbar = false;
                      form2.Parent = this;
                      form2.Name = "form2";
                      form2.Text = "form2";
                      form2.Size = new Size(300, 200);
                      form2.Show();
                      form2.BringToFront();
              

              You now have a Form that is in front of your MainForm, and that, depending on FormBorderStyle, can be moved around so parts of it are invisible, as they extend beyond the DisplayRectangle of the MainForm. Depending on its z-order within the Form ... that is if some other control on the Form has been brought-to-the-front: it could appear "behind" other Controls on the Form. Consider that you create a Form which is not a ChildForm: like this:

                      Form form2 = new Form();
                      form2.ShowInTaskbar = false;
                      form2.Name = "form2";
                      form2.Text = "form2";
                      form2.Size = new Size(300, 200);
                      form2.Show();
                      form2.BringToFront();
              

              Now you have a Form you can move anywhere on the screen, depending on the setting of FormBorderStyle, and it will always be visible ... unless you activate the MainForm and bring it to the front, and the MainForm covers part of the second Form. If you wanted this new Form to always remain on top, no matter whether the MainForm was activated, or not: just set the new Form's TopMost property to 'true, while making the sure the MainForm's TopMost property is set to 'false. Another area to investigate, if you are concerned with your new Form always appearing on top, is the use of 'ShowModal(), in contrast to 'Show(). Keep in mind that: if your WinForms project opens in the rather standard way by creating an instance of the MainForm in the Program.cs class: that closing the MainForm will always automatically close any secondary Forms created. In eith

              L 1 Reply Last reply
              0
              • B BillWoodruff

                Hi, First, I believe that Child Forms should never be used, that they lead to awkward user-interfaces, and the old MDI-architecture, which supported MDIChildForms with "special features," deserves the status of a "dinosaur" skeleton: to be looked at, but not re-animated :) I think you can get better responses to this scenario if you describe what the function of your proposed use of "Child Forms" are, in relation to their "Parent" Form. Is it possible a Dialog can fit your needs here ? Consider that you create a "Child Form" with code like this in response to some event:

                        Form form2 = new Form();
                        form2.TopLevel = false; // mandatory for Child Forms
                        form2.ShowInTaskbar = false;
                        form2.Parent = this;
                        form2.Name = "form2";
                        form2.Text = "form2";
                        form2.Size = new Size(300, 200);
                        form2.Show();
                        form2.BringToFront();
                

                You now have a Form that is in front of your MainForm, and that, depending on FormBorderStyle, can be moved around so parts of it are invisible, as they extend beyond the DisplayRectangle of the MainForm. Depending on its z-order within the Form ... that is if some other control on the Form has been brought-to-the-front: it could appear "behind" other Controls on the Form. Consider that you create a Form which is not a ChildForm: like this:

                        Form form2 = new Form();
                        form2.ShowInTaskbar = false;
                        form2.Name = "form2";
                        form2.Text = "form2";
                        form2.Size = new Size(300, 200);
                        form2.Show();
                        form2.BringToFront();
                

                Now you have a Form you can move anywhere on the screen, depending on the setting of FormBorderStyle, and it will always be visible ... unless you activate the MainForm and bring it to the front, and the MainForm covers part of the second Form. If you wanted this new Form to always remain on top, no matter whether the MainForm was activated, or not: just set the new Form's TopMost property to 'true, while making the sure the MainForm's TopMost property is set to 'false. Another area to investigate, if you are concerned with your new Form always appearing on top, is the use of 'ShowModal(), in contrast to 'Show(). Keep in mind that: if your WinForms project opens in the rather standard way by creating an instance of the MainForm in the Program.cs class: that closing the MainForm will always automatically close any secondary Forms created. In eith

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                BillWoodruff wrote:

                First, I believe that Child Forms should never be used, that they lead to awkward user-interfaces, and the old MDI-architecture

                ..I'd like to see a version of Visual Studio with an SDI-interface. MDI isn't dead, it's merely abused a lot. We'll say the same thing about that Ribbon on a few years :)

                BillWoodruff wrote:

                I think you can get better responses to this scenario if you describe what the function of your proposed use of "Child Forms" are, in relation to their "Parent" Form.

                Good point; when an apparant beginner talks about child-forms, I usually assume (I know, we should check, not assume) that they need to display a dialog, and that they forgot to specify the owner of the form (often confused with the parent). +5 for giving a very elaborate answer that does not only benefit the TS.

                Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                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