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. .NET (Core and Framework)
  4. Opening a form inside another

Opening a form inside another

Scheduled Pinned Locked Moved .NET (Core and Framework)
designquestion
8 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.
  • R Offline
    R Offline
    Ricky Helgesson
    wrote on last edited by
    #1

    I am developing an application where I am seeking the look and feel of Microsoft Outlook. I have created some forms for my different objects (contracts, suppliers etc.). I have created ContractListForm, ContractForm, SupplierListForm and SupplierForm among others. Now, in my main form, I have a toolbar to the left and when the user clicks one of the buttons, I want to open up the correct *ListForm to the right (not in a new window). Is this possible? If not, how should I design this? I would like to be able to do just like in Outlook, where the user can chose to open the Inbox for instance either to the right, or in a new window. /Ricky

    M J M 3 Replies Last reply
    0
    • R Ricky Helgesson

      I am developing an application where I am seeking the look and feel of Microsoft Outlook. I have created some forms for my different objects (contracts, suppliers etc.). I have created ContractListForm, ContractForm, SupplierListForm and SupplierForm among others. Now, in my main form, I have a toolbar to the left and when the user clicks one of the buttons, I want to open up the correct *ListForm to the right (not in a new window). Is this possible? If not, how should I design this? I would like to be able to do just like in Outlook, where the user can chose to open the Inbox for instance either to the right, or in a new window. /Ricky

      M Offline
      M Offline
      mikelb
      wrote on last edited by
      #2

      What I did one time when I was trying to do the same thing was put a panel control where you want the form to go. The panel control, if I remember correctly, is able to "host" a form so you just create an instance of the form and add it to the panels controls.

      R 1 Reply Last reply
      0
      • R Ricky Helgesson

        I am developing an application where I am seeking the look and feel of Microsoft Outlook. I have created some forms for my different objects (contracts, suppliers etc.). I have created ContractListForm, ContractForm, SupplierListForm and SupplierForm among others. Now, in my main form, I have a toolbar to the left and when the user clicks one of the buttons, I want to open up the correct *ListForm to the right (not in a new window). Is this possible? If not, how should I design this? I would like to be able to do just like in Outlook, where the user can chose to open the Inbox for instance either to the right, or in a new window. /Ricky

        J Offline
        J Offline
        Jasper4C
        wrote on last edited by
        #3

        You can somehow set ID numbers to the buttons on your toolbar and then catch every event from this button or something like this private void button1_click (la la la ..) { ContractListForm frm1 = new ContractListForm(); this.Hide(); frm1.Show(); } "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931)

        1 Reply Last reply
        0
        • M mikelb

          What I did one time when I was trying to do the same thing was put a panel control where you want the form to go. The panel control, if I remember correctly, is able to "host" a form so you just create an instance of the form and add it to the panels controls.

          R Offline
          R Offline
          Ricky Helgesson
          wrote on last edited by
          #4

          I have already tried that but when i Run: myPanel.Controls.Add(myForm); ...I get an error message something like this: "You can not add a top-level control to a control". (I should have written that in my first post.) So, do you know if it still is possible any other way? /Ricky

          M 1 Reply Last reply
          0
          • R Ricky Helgesson

            I have already tried that but when i Run: myPanel.Controls.Add(myForm); ...I get an error message something like this: "You can not add a top-level control to a control". (I should have written that in my first post.) So, do you know if it still is possible any other way? /Ricky

            M Offline
            M Offline
            mikelb
            wrote on last edited by
            #5

            What I did was this, and it works for me: In the constructor code for the form add: this.TopLevel = false; In your main form use this: frmAddNew add = new frmAddNew( ); add.Parent = panelWorkArea; panelWorkArea.Controls.Add( add ); add.Visible = true; Let me know if that works for you.

            R 1 Reply Last reply
            0
            • R Ricky Helgesson

              I am developing an application where I am seeking the look and feel of Microsoft Outlook. I have created some forms for my different objects (contracts, suppliers etc.). I have created ContractListForm, ContractForm, SupplierListForm and SupplierForm among others. Now, in my main form, I have a toolbar to the left and when the user clicks one of the buttons, I want to open up the correct *ListForm to the right (not in a new window). Is this possible? If not, how should I design this? I would like to be able to do just like in Outlook, where the user can chose to open the Inbox for instance either to the right, or in a new window. /Ricky

              M Offline
              M Offline
              MtnBiknGuy
              wrote on last edited by
              #6

              One other approach would be to derive all your *ListForms from UserControl instead of Form. You can still use the forms designer with a UserControl. I don't think you will lose much, if any, functionality that you need, but you may have more flexibility for reusing the *ListForms and for hosting them in any type of control or form. I've also been wondering about the best approach for something like this, so I would like to pose a general question to the group. To create the type of "Outlook" UI Ricky asks about, is it better to use Forms or Controls (such as UserControl)? Which has more flexibility? Which is easier for RAD UI development? Which has more support and is more widely used? Which is easier for integrating menus, toolbars, etc.? In my case, I have two choices. I could use either a tabbed MDI host (like in VS.NET) with multiple forms, or I could use various host controls (including tab controls, etc.) to display my own UserControl-derived objects. Any comments are appreciated. Dave

              1 Reply Last reply
              0
              • M mikelb

                What I did was this, and it works for me: In the constructor code for the form add: this.TopLevel = false; In your main form use this: frmAddNew add = new frmAddNew( ); add.Parent = panelWorkArea; panelWorkArea.Controls.Add( add ); add.Visible = true; Let me know if that works for you.

                R Offline
                R Offline
                Ricky Helgesson
                wrote on last edited by
                #7

                Thank you! That works just fine. Next, I will try to get rid of the form border. I quickly found the ways to remove the system, minimize, maximize and close buttons. I docked the form to the panel so when the panel (inside it's form) resizes, the subform follows. Perfect... but, the user still sees the window border and caption and can manually resize the form. I suppose it's very easily removed but I simply have not found the command yet. My knowledge in Windows Forms seems quite rudamentary yet. /Ricky

                M 1 Reply Last reply
                0
                • R Ricky Helgesson

                  Thank you! That works just fine. Next, I will try to get rid of the form border. I quickly found the ways to remove the system, minimize, maximize and close buttons. I docked the form to the panel so when the panel (inside it's form) resizes, the subform follows. Perfect... but, the user still sees the window border and caption and can manually resize the form. I suppose it's very easily removed but I simply have not found the command yet. My knowledge in Windows Forms seems quite rudamentary yet. /Ricky

                  M Offline
                  M Offline
                  mikelb
                  wrote on last edited by
                  #8

                  No problem, glad it helped. For the border, just set the border style to none and the title and resize-ability will go away. Michael

                  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