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. Is it possible to add a form to a panel?

Is it possible to add a form to a panel?

Scheduled Pinned Locked Moved C#
question
5 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.
  • Z Offline
    Z Offline
    zuhx
    wrote on last edited by
    #1

    Does any one know if it is possible to add a form to a panel? Thanks

    S J 2 Replies Last reply
    0
    • Z zuhx

      Does any one know if it is possible to add a form to a panel? Thanks

      S Offline
      S Offline
      shaunAustin
      wrote on last edited by
      #2

      I don't think so... You should use a UserControl... HTH Shaun

      1 Reply Last reply
      0
      • Z zuhx

        Does any one know if it is possible to add a form to a panel? Thanks

        J Offline
        J Offline
        James T Johnson
        wrote on last edited by
        #3

        zuhx wrote: Does any one know if it is possible to add a form to a panel? Yes, it is possible, but not really recommended unless you change the FormBorderStyle.

        MyForm form = new MyForm();
        form.TopLevel = false;
        form.Location = new Point(5, 5);

        this.Controls.Add(form);
        form.Show();

        The only two things you HAVE to do is set TopLevel to false, and call Show. Don't forget that if the user clicks the close button on the form then the form object get's Dispose'd -- yet another reason to change the forms FormBorderStyle or at least hook the form's Closing event. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

        Z 1 Reply Last reply
        0
        • J James T Johnson

          zuhx wrote: Does any one know if it is possible to add a form to a panel? Yes, it is possible, but not really recommended unless you change the FormBorderStyle.

          MyForm form = new MyForm();
          form.TopLevel = false;
          form.Location = new Point(5, 5);

          this.Controls.Add(form);
          form.Show();

          The only two things you HAVE to do is set TopLevel to false, and call Show. Don't forget that if the user clicks the close button on the form then the form object get's Dispose'd -- yet another reason to change the forms FormBorderStyle or at least hook the form's Closing event. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

          Z Offline
          Z Offline
          zuhx
          wrote on last edited by
          #4

          James T. Johnson wrote: Yes, it is possible, but not really recommended unless you change the FormBorderStyle. I do need to change the FormBorderStyle. Can you give a little more detail on why it is not recommended? Is it only because of changing the FormBorderStyle or are there other reasons as well?

          J 1 Reply Last reply
          0
          • Z zuhx

            James T. Johnson wrote: Yes, it is possible, but not really recommended unless you change the FormBorderStyle. I do need to change the FormBorderStyle. Can you give a little more detail on why it is not recommended? Is it only because of changing the FormBorderStyle or are there other reasons as well?

            J Offline
            J Offline
            James T Johnson
            wrote on last edited by
            #5

            zuhx wrote: Can you give a little more detail on why it is not recommended? I don't recommend adding a form to a panel UNLESS you change the border style. Otherwise you wind up with a form that can be moved around (not so bad if that is the intended purpose) but it can also be closed which can be a problem. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

            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