Compartilhar via


Panel Control Overview (Windows Forms)

Windows Forms Panel controls are used to provide an identifiable grouping for other controls. Typically, you use panels to subdivide a form by function. For example, you may have an order form that specifies mailing options such as which overnight carrier to use. Grouping all options in a panel gives the user a logical visual cue. At design time all the controls can be moved easily — when you move the Panel control, all its contained controls move, too. The controls grouped in a panel can be accessed through its Controls property. This property returns a collection of Control instances, so you will typically need to cast a control retrieved this way to its specific type.

Panel Versus GroupBox

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.

Key Properties

To display scroll bars, set the AutoScroll property to true. You can also customize the appearance of the panel by setting the BackColor, BackgroundImage, and BorderStyle properties. For more information on the BackColor and BackgroundImage properties, see How to: Set the Background of a Windows Forms Panel. The BorderStyle property determines if the panel is outlined with no visible border (None), a plain line (FixedSingle), or a shadowed line (Fixed3D).

See Also

Reference

Panel

Other Resources

GroupBox Control (Windows Forms)