Skip to main content
A newer version of this page is available. .

StackPanel Class

A panel that arranges its child element into a single line that can be oriented either vertically or horizontally.

Namespace: DevExpress.Utils.Layout

Assembly: DevExpress.Utils.v19.2.dll

Declaration

[Docking(DockingBehavior.Never)]
[ToolboxBitmap(typeof(ToolboxIconsRootNS), "StackPanel")]
public class StackPanel :
    XtraLayoutPanelBase,
    IStackPanel,
    IXtraLayoutPanel

Remarks

The Stack Layout Panel arranges its child controls in one of four directions depending on the StackPanel.LayoutDirection setting. The figure below illustrates controls the top-to-bottom element direction.

stack-panel

To populate a panel at design-time, drag required controls from the Visual Studio Toolbox and drop them onto the panel. You can drag child panel elements to re-arrange them.

To populate a stack panel in code, add required elements to the panel’s Controls collection.

 stackPanel1.Controls.Add(this.labelControl6);
 stackPanel1.Controls.Add(this.textEdit5);
 stackPanel1.Controls.Add(this.labelControl5);
 stackPanel1.Controls.Add(this.textEdit6);
 stackPanel1.Controls.Add(this.labelControl4);
 stackPanel1.Controls.Add(this.textEdit8);
 stackPanel1.Controls.Add(this.labelControl3);
 stackPanel1.Controls.Add(this.textEdit9);
 stackPanel1.Controls.Add(this.simpleButton5);
 stackPanel1.Controls.Add(this.simpleButton6);
 stackPanel1.LayoutDirection = DevExpress.Utils.Layout.StackPanelLayoutDirection.TopBottom;
 stackPanel1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 0);

You can stretch a control to make it occupy all the free space available in a stack panel. To do that at design time, enable the control’s Stretched extender property. In the figure below, a TextEdit control lying in between two SimpleButtons is stretched.

stack-panel

To do that in code, call the StackPanel.SetStretched(Control, Boolean) method and pass the required control as the first method parameter.

stackPanel3.SetStretched(textEdit10, true);

Note that the size of a stretched control cannot exceed this control’s MaximumSize.

Inheritance

Show 11 items
Object
MarshalByRefObject
Component
Control
ScrollableControl
XtraScrollableControl
XtraPanel
DevExpress.Utils.Controls.PanelBase
PanelControl
DevExpress.Utils.Layout.XtraLayoutPanelBase
StackPanel
See Also