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.
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.
To do that in code, call the StackPanel.SetStretched(Control, Boolean) method and pass the required control as the first method parameter.
Note that the size of a stretched control cannot exceed this control’s MaximumSize.