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. Visual Basic
  4. Panel + Groupbox

Panel + Groupbox

Scheduled Pinned Locked Moved Visual Basic
questionhelp
10 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.
  • C Offline
    C Offline
    codemunkeh
    wrote on last edited by
    #1

    Having become lazy, I've done so much as to check MSDN. Basically I have a panel, and a bunch of groupboxes which I would like on that panel. The groupboxes are hidden/displayed and moved depending on the user instructions at runtime. It all worked great without the panel (simply on the form), but with it, it doesn't. The panel contains a button to hide it, which no longer works, and the groupboxes don't appear in the panel, regardless of whether or not I have them in the panel within the designer. My question isn't fix it but, is there some trick I've missed with panels, to make their contents display? It works, in that it displays the button and the button changes on mouseovers, but it doesn't work. It seems that the panel doesn't redraw itself entirely, but I added some calls to refresh it after moving the panels which has no effect.


    Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

    D C 2 Replies Last reply
    0
    • C codemunkeh

      Having become lazy, I've done so much as to check MSDN. Basically I have a panel, and a bunch of groupboxes which I would like on that panel. The groupboxes are hidden/displayed and moved depending on the user instructions at runtime. It all worked great without the panel (simply on the form), but with it, it doesn't. The panel contains a button to hide it, which no longer works, and the groupboxes don't appear in the panel, regardless of whether or not I have them in the panel within the designer. My question isn't fix it but, is there some trick I've missed with panels, to make their contents display? It works, in that it displays the button and the button changes on mouseovers, but it doesn't work. It seems that the panel doesn't redraw itself entirely, but I added some calls to refresh it after moving the panels which has no effect.


      Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

      D Offline
      D Offline
      Dave Herren
      wrote on last edited by
      #2

      Without some brief, relevant snippits of your code it would be hard to help you. Also, don't call yourself lazy, even if you are; admitting to being lazy, and yet expect that I, or anyone else here help you, seems insulting and as a general rule I tend not to help people who insult me.

      topcoderjax - Remember, Google is your friend.

      C 1 Reply Last reply
      0
      • D Dave Herren

        Without some brief, relevant snippits of your code it would be hard to help you. Also, don't call yourself lazy, even if you are; admitting to being lazy, and yet expect that I, or anyone else here help you, seems insulting and as a general rule I tend not to help people who insult me.

        topcoderjax - Remember, Google is your friend.

        C Offline
        C Offline
        codemunkeh
        wrote on last edited by
        #3

        The laziness was about me...because for the last 4 years (before I became more reliant on the internet) I could sit for hours testing and testing until it worked, or I came up with something better. This time I've given in because I know there are plenty of people out there who do nothing but use panels for their interface (and they work). There's no code needed, I would expect. All of the following was/is done at design-time. There's a form. Upon that, are groupboxes. Without any panels, the groupboxes display and the buttons work fine (they execute their click events). Then I added the panel, moved the groupboxes so that they were [definitely] in the panel, and the relevant buttons too. Now, the buttons appear but do nothing when clicking on them, and the groupboxes don't appear. All of the groupboxes initially have their Visible property set to false. The buttons are visible. Hopefully that's clear enough.


        Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

        D 1 Reply Last reply
        0
        • C codemunkeh

          The laziness was about me...because for the last 4 years (before I became more reliant on the internet) I could sit for hours testing and testing until it worked, or I came up with something better. This time I've given in because I know there are plenty of people out there who do nothing but use panels for their interface (and they work). There's no code needed, I would expect. All of the following was/is done at design-time. There's a form. Upon that, are groupboxes. Without any panels, the groupboxes display and the buttons work fine (they execute their click events). Then I added the panel, moved the groupboxes so that they were [definitely] in the panel, and the relevant buttons too. Now, the buttons appear but do nothing when clicking on them, and the groupboxes don't appear. All of the groupboxes initially have their Visible property set to false. The buttons are visible. Hopefully that's clear enough.


          Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

          D Offline
          D Offline
          Dave Herren
          wrote on last edited by
          #4

          I tried to duplicate your problem doing the following: added a panel to a form put a groupbox on the panel put a button on the groupbox set the visible property on all three to false. set the visible property of all three to true on the for double click event of the form. put messagebox.show("Test") in the click event of the button. ran the app. double clicked the form; The panel, groupbox, and button showed. clicked the button and it worked. The windows forms designed code for what I did is: this.panel1 = new System.Windows.Forms.Panel(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.groupBox1); this.panel1.Location = new System.Drawing.Point(72, 56); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(400, 320); this.panel1.TabIndex = 0; this.panel1.Visible = false; // // groupBox1 // this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(32, 32); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(336, 264); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "groupBox1"; this.groupBox1.Visible = false; // // button1 // this.button1.Location = new System.Drawing.Point(40, 48); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 24); this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Visible = false; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(576, 469); this.Controls.Add(this.panel1); this.Name = "Form2"; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load); this.DoubleClick += new System.EventHandler(this.Form2_DoubleClick); this.panel1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); Review your forms designer code and see if you see anything weird. If not, try and duplicate your problem in the simplest possible way and outline it as I did above.

          topcoderjax - Remember, Google is your friend.

          C 1 Reply Last reply
          0
          • D Dave Herren

            I tried to duplicate your problem doing the following: added a panel to a form put a groupbox on the panel put a button on the groupbox set the visible property on all three to false. set the visible property of all three to true on the for double click event of the form. put messagebox.show("Test") in the click event of the button. ran the app. double clicked the form; The panel, groupbox, and button showed. clicked the button and it worked. The windows forms designed code for what I did is: this.panel1 = new System.Windows.Forms.Panel(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.groupBox1); this.panel1.Location = new System.Drawing.Point(72, 56); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(400, 320); this.panel1.TabIndex = 0; this.panel1.Visible = false; // // groupBox1 // this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(32, 32); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(336, 264); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "groupBox1"; this.groupBox1.Visible = false; // // button1 // this.button1.Location = new System.Drawing.Point(40, 48); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 24); this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Visible = false; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(576, 469); this.Controls.Add(this.panel1); this.Name = "Form2"; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load); this.DoubleClick += new System.EventHandler(this.Form2_DoubleClick); this.panel1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); Review your forms designer code and see if you see anything weird. If not, try and duplicate your problem in the simplest possible way and outline it as I did above.

            topcoderjax - Remember, Google is your friend.

            C Offline
            C Offline
            codemunkeh
            wrote on last edited by
            #5

            Having followed your guide (except, in VB this time :-D) I get the same results as you and I and any sane person would expect. I had a panel, a visible button which made an invisible groupbox, visible. The original project still ain't working. The data's working, it seems that the panel can't handle things moving around inside of it. Thanks for your time, but I'll go bury my head in some strange code for now. There's only so many psychologists willing to help frustrated programmers left.


            Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

            D D 2 Replies Last reply
            0
            • C codemunkeh

              Having followed your guide (except, in VB this time :-D) I get the same results as you and I and any sane person would expect. I had a panel, a visible button which made an invisible groupbox, visible. The original project still ain't working. The data's working, it seems that the panel can't handle things moving around inside of it. Thanks for your time, but I'll go bury my head in some strange code for now. There's only so many psychologists willing to help frustrated programmers left.


              Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

              D Offline
              D Offline
              Dave Herren
              wrote on last edited by
              #6

              Something keeps tickling the tip of my brain. An odd problem I once had when dragging exising controls into a panel. Can't remember the details, but seem to remember (and it will be a huge pain to do this) that I ended up starting over and creating a new form and adding a panel and new controls in the panel and the problem cleared up. Meant I had to copy over all of the other code from the existing form and of course recreating the whole ui itself is a pain, but when you truely have given up it might be worth a try.

              topcoderjax - Remember, Google is your friend.

              C 1 Reply Last reply
              0
              • C codemunkeh

                Having followed your guide (except, in VB this time :-D) I get the same results as you and I and any sane person would expect. I had a panel, a visible button which made an invisible groupbox, visible. The original project still ain't working. The data's working, it seems that the panel can't handle things moving around inside of it. Thanks for your time, but I'll go bury my head in some strange code for now. There's only so many psychologists willing to help frustrated programmers left.


                Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Your groupbox's (if I followed this thread correctly) are not in your panel controls. It can appear on top of or under the panel, but you didn't drop the groupbox from the Toolbox ON the panel. You dropped it on the form, then tried to move it into the panel. This just moves the groupbox over the top of the panel. All you have to do is add the groupbox control(s) to the Panel's Controls collection:

                Panel1.Controls.Add(myGroupBox)
                

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                C 1 Reply Last reply
                0
                • D Dave Herren

                  Something keeps tickling the tip of my brain. An odd problem I once had when dragging exising controls into a panel. Can't remember the details, but seem to remember (and it will be a huge pain to do this) that I ended up starting over and creating a new form and adding a panel and new controls in the panel and the problem cleared up. Meant I had to copy over all of the other code from the existing form and of course recreating the whole ui itself is a pain, but when you truely have given up it might be worth a try.

                  topcoderjax - Remember, Google is your friend.

                  C Offline
                  C Offline
                  codemunkeh
                  wrote on last edited by
                  #8

                  Funnily enough, I did just that last night. Had a second project, copied the form and relevant code over. It's the bare minimum to have it working as it was - still doesn't work though. I daresay I could do it the long way around. There's 4 groupboxes causing problems and each has less than 10 controls on it. Nothing really complex, and there's not exactly a deadline.


                  Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

                  1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    Your groupbox's (if I followed this thread correctly) are not in your panel controls. It can appear on top of or under the panel, but you didn't drop the groupbox from the Toolbox ON the panel. You dropped it on the form, then tried to move it into the panel. This just moves the groupbox over the top of the panel. All you have to do is add the groupbox control(s) to the Panel's Controls collection:

                    Panel1.Controls.Add(myGroupBox)
                    

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    C Offline
                    C Offline
                    codemunkeh
                    wrote on last edited by
                    #9

                    Unfortunately, I made sure of it. Dragging them over, and then within the panel to the edge of it, it stops drawing outside of the panel. I also checked and the pnlPanels.Controls.Add() lines were all in the designer code, and that was what I got from MSDN - adding those lines to my Form_Load code. Plus, sometimes (not always) when you drag a control within a panel or a groupbox, the cursor changes and a dotted box appears next to it. Not very obvious if you're working at speed though.


                    Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

                    1 Reply Last reply
                    0
                    • C codemunkeh

                      Having become lazy, I've done so much as to check MSDN. Basically I have a panel, and a bunch of groupboxes which I would like on that panel. The groupboxes are hidden/displayed and moved depending on the user instructions at runtime. It all worked great without the panel (simply on the form), but with it, it doesn't. The panel contains a button to hide it, which no longer works, and the groupboxes don't appear in the panel, regardless of whether or not I have them in the panel within the designer. My question isn't fix it but, is there some trick I've missed with panels, to make their contents display? It works, in that it displays the button and the button changes on mouseovers, but it doesn't work. It seems that the panel doesn't redraw itself entirely, but I added some calls to refresh it after moving the panels which has no effect.


                      Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

                      C Offline
                      C Offline
                      codemunkeh
                      wrote on last edited by
                      #10

                      I've given up. The reason I needed the panel was because I wanted to use GDI to draw on the rest of the window and the panel seemed the easiest way of me not having to draw under the groupboxes. So I figured, dispose of the panel (well, delete it - it's not being created to be disposed :-P) and just add another (complex) rectangle to the GDI code. Thanks anyway folks, but it seems like one of those bugs that just happens.


                      Yet another spam post on yet another forum! I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to. I love being a student.

                      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