So I am designing a control with a window s form. I want to group some controls together with a caption. So naturally I would go with a GroupBox. However is there some advantage in using a panel instead? Something not immediatly obvious to one who is still a little green with form design? How about some "gotchas" as well.
views:
171answers:
5A groupbox may have a caption, whereas a panel may not. A Panel may have scroll bars whereas a group box may not.
Some Advantages of Panel:
- Scrollable
- Lots of border style options.
An Advantage of GroupBox:
- Group Title
A Group Box just provides a graphical outline of the extent of the container, and a caption at the top. A panel can scroll it's contents automatically, where as a group box would not be able to without some form of intervention (Panel inside a group box).
The Panel control is similar to the GroupBox control; however, only the Panel control can have scroll bars, and only the GroupBox control displays a caption.
Also border styles of GroupBox and Panel are different
In most cases Panels are used when you want to group several controls and apply an Anchor or Dock for the whole group.
Very seldom panels have borders. If you like a caption and border around a group of controls, using GroupBox will be more natural.