# DynamicLayout class

Namespace: [Eto.Forms](https://eto.picoe.ca/api/namespace/eto.forms.md) · Assembly: [Eto](https://eto.picoe.ca/api/assembly/eto.md)

```cs
[ContentProperty("Rows")]
public class DynamicLayout : Panel
```

Dynamic and extensible layout

**Remarks:** The dynamic layout allows you to build a complex structure of controls easily. The core functionality allows you to build a hierarchical set of tables with rows and columns of controls. A vertical section begins a new table, whereas a horizontal section refers to a row in a table. The dynamic layout intrinsically starts with a vertical section. You can define your layout verbosely or succinctly as you see fit. The Begin.../End... methods allow you define the vertical/horizontal sections individually with separate commands, whereas you can also create a layout entirely with a constructor or initializer pattern using the [DynamicLayout.Rows](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/rows.md), [DynamicTable.Rows](https://eto.picoe.ca/api/type/eto.forms.dynamictable/rows.md), and [DynamicRow.Items](https://eto.picoe.ca/api/type/eto.forms.dynamicrow/items.md) properties. To learn about how scaling works, see [TableLayout](https://eto.picoe.ca/api/type/eto.forms.tablelayout.md)

**Example:**

This example uses the verbose methods creating sections in separate statements

```cs
var layout = new DynamicLayout();

layout.BeginHorizontal();
layout.Add(new Label { Text = "My Label" });
layout.Add(new TextBox());
layout.EndHorizontal();

layout.BeginHorizontal()
layout.Add(new Label { Text = "Vertical controls:" });

layout.BeginVertical(padding: new Padding(10));
layout.Add(new TextBox());
layout.Add(new Label { Text = "Some text below the text box" });
layout.EndVertical();

layout.EndHorizontal();
```

 This example uses the constructor method:

```cs
var layout = new DynamicLayout(
	new DynamicRow(
		new Label { Text = "My Label" },
		new TextBox()
	),
	new DynamicRow(
		new Label { Text = "Vertical controls:" },
		new DynamicTable(
			new TextBox(),
			new Label { Text = "Some text below the text box" }
		) { Padding = new Padding(10) }
	)
);
```

 And finally the initializer pattern, which allows you to set other properties of rows/tables cleaner, such as padding/spacing/scaling:

```cs
var layout = new DynamicLayout { Rows = {
	new DynamicRow { Items = {
		new Label { Text = "My Label" },
		new TextBox()
	} },
	new DynamicRow { Items = {
		new Label { Text = "Vertical controls:" },
		new DynamicTable { Padding = new Padding(10), Rows = {
			new TextBox(),
			new Label { Text = "Some text below the text box" }
		} }
	} }
} };
```

## Constructors

- [DynamicLayout](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/ctor.md): (3 overloads) Initializes a new instance of the [DynamicLayout](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout.md) class.

## Properties

- [Controls](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/controls.md): Gets an enumeration of controls that are directly contained by this container
- [DefaultPadding](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/defaultpadding.md): Gets or sets the default padding for all child [DynamicTable](https://eto.picoe.ca/api/type/eto.forms.dynamictable.md) instances (vertical sections)
- [DefaultSpacing](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/defaultspacing.md): Gets or sets the default spacing for all cells in the layout
- [IsCreated](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/iscreated.md): Gets a value indicating whether the layout has been created
- [Padding](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/padding.md): Gets or sets the padding around the entire content of the layout
- [Rows](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/rows.md): Gets or sets the top level rows in the layout
- [Spacing](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/spacing.md): Gets or sets the spacing between the first level of cells
- [VisualControls](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/visualcontrols.md): Gets an enumeration of controls that are in the visual tree.

## Methods

- [Add](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/add.md): Add the control with the optional scaling
- [AddAutoSized](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addautosized.md): Adds a control to the layout with its preferred size instead of taking the entire space of the cell
- [AddCentered](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addcentered.md): Adds a control centered in a new vertical section
- [AddColumn](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addcolumn.md): Adds a column of controls in a new vertical section
- [AddRange](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addrange.md): (2 overloads) Adds a list of controls
- [AddRow](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addrow.md): Adds a new row of controls to the current vertical section
- [AddSeparateColumn](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addseparatecolumn.md): (2 overloads) Adds a separate vertical column of items in a new vertical section
- [AddSeparateRow](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addseparaterow.md): (2 overloads) Adds a separate horizontal row of items in a new vertical section
- [AddSpace](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/addspace.md): Adds an empty space. Equivalent to calling Add(null);
- [BeginCentered](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/begincentered.md): Creates a new section where all controls will be centered together.
- [BeginGroup](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/begingroup.md): Begins a the group section in the dynamic layout with a title.
- [BeginHorizontal](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/beginhorizontal.md): Begins a new horizontal row section
- [BeginScrollable](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/beginscrollable.md): Begins a the scrollable section in the dynamic layout with a specified border.
- [BeginVertical](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/beginvertical.md): Begins a new vertical section in the layout
- [Clear](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/clear.md): Clears the layout so it can be recreated
- [Create](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/create.md): Creates the layout content
- [EndBeginHorizontal](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endbeginhorizontal.md): Ends the current horizontal section, then begins a new horizontal section with a new row
- [EndBeginVertical](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endbeginvertical.md): Ends the current vertical section, then begins a new vertical section
- [EndCentered](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endcentered.md): Ends the current centered section.
- [EndGroup](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endgroup.md): Ends a group.
- [EndHorizontal](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endhorizontal.md): Ends the current horizontal section
- [EndScrollable](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endscrollable.md): Ends a scrollable section.
- [EndVertical](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/endvertical.md): Ends the current vertical section
- [OnLoad](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/onload.md): Raises the [Control.Load](https://eto.picoe.ca/api/type/eto.forms.control/load.md) event, and creates the layout if it has not been created
- [OnPreLoad](https://eto.picoe.ca/api/type/eto.forms.dynamiclayout/onpreload.md): Raises the [Control.PreLoad](https://eto.picoe.ca/api/type/eto.forms.control/preload.md) event, and creates the layout if it has not been created

## Inherited Members

- From [Panel](https://eto.picoe.ca/api/type/eto.forms.panel.md): [Content](https://eto.picoe.ca/api/type/eto.forms.panel/content.md), [ContextMenu](https://eto.picoe.ca/api/type/eto.forms.panel/contextmenu.md), [MinimumSize](https://eto.picoe.ca/api/type/eto.forms.panel/minimumsize.md), [Remove](https://eto.picoe.ca/api/type/eto.forms.panel/remove.md)
- From [Container](https://eto.picoe.ca/api/type/eto.forms.container.md): [Children](https://eto.picoe.ca/api/type/eto.forms.container/children.md), [ClientSize](https://eto.picoe.ca/api/type/eto.forms.container/clientsize.md), [StyleProvider](https://eto.picoe.ca/api/type/eto.forms.container/styleprovider.md), [Styles](https://eto.picoe.ca/api/type/eto.forms.container/styles.md), [VisualChildren](https://eto.picoe.ca/api/type/eto.forms.container/visualchildren.md), [ApplyStyles](https://eto.picoe.ca/api/type/eto.forms.container/applystyles.md), [FindChild](https://eto.picoe.ca/api/type/eto.forms.container/findchild.md), [OnLoadComplete](https://eto.picoe.ca/api/type/eto.forms.container/onloadcomplete.md), [OnStyleChanged](https://eto.picoe.ca/api/type/eto.forms.container/onstylechanged.md), [OnUnLoad](https://eto.picoe.ca/api/type/eto.forms.container/onunload.md), [Remove](https://eto.picoe.ca/api/type/eto.forms.container/remove.md), [RemoveAll](https://eto.picoe.ca/api/type/eto.forms.container/removeall.md), [RemoveLogicalParent](https://eto.picoe.ca/api/type/eto.forms.container/removelogicalparent.md), [RemoveParent](https://eto.picoe.ca/api/type/eto.forms.container/removeparent.md), [SetLogicalParent](https://eto.picoe.ca/api/type/eto.forms.container/setlogicalparent.md), [SetParent](https://eto.picoe.ca/api/type/eto.forms.container/setparent.md)
- From [Control](https://eto.picoe.ca/api/type/eto.forms.control.md): [AllowDrop](https://eto.picoe.ca/api/type/eto.forms.control/allowdrop.md), [BackgroundColor](https://eto.picoe.ca/api/type/eto.forms.control/backgroundcolor.md), [Bounds](https://eto.picoe.ca/api/type/eto.forms.control/bounds.md), [Cursor](https://eto.picoe.ca/api/type/eto.forms.control/cursor.md), [Enabled](https://eto.picoe.ca/api/type/eto.forms.control/enabled.md), [Gestures](https://eto.picoe.ca/api/type/eto.forms.control/gestures.md), [Handler](https://eto.picoe.ca/api/type/eto.forms.control/handler.md), [HasFocus](https://eto.picoe.ca/api/type/eto.forms.control/hasfocus.md), [Height](https://eto.picoe.ca/api/type/eto.forms.control/height.md), [IsAttached](https://eto.picoe.ca/api/type/eto.forms.control/isattached.md), [IsMouseCaptured](https://eto.picoe.ca/api/type/eto.forms.control/ismousecaptured.md), [IsSuspended](https://eto.picoe.ca/api/type/eto.forms.control/issuspended.md), [IsVisualControl](https://eto.picoe.ca/api/type/eto.forms.control/isvisualcontrol.md), [Loaded](https://eto.picoe.ca/api/type/eto.forms.control/loaded.md), [Location](https://eto.picoe.ca/api/type/eto.forms.control/location.md), [LogicalParent](https://eto.picoe.ca/api/type/eto.forms.control/logicalparent.md), [Parent](https://eto.picoe.ca/api/type/eto.forms.control/parent.md), [ParentWindow](https://eto.picoe.ca/api/type/eto.forms.control/parentwindow.md), [Size](https://eto.picoe.ca/api/type/eto.forms.control/size.md), [SupportedPlatformCommands](https://eto.picoe.ca/api/type/eto.forms.control/supportedplatformcommands.md), [TabIndex](https://eto.picoe.ca/api/type/eto.forms.control/tabindex.md), [TabStop](https://eto.picoe.ca/api/type/eto.forms.control/tabstop.md), [Tag](https://eto.picoe.ca/api/type/eto.forms.control/tag.md), [ToolTip](https://eto.picoe.ca/api/type/eto.forms.control/tooltip.md), [Visible](https://eto.picoe.ca/api/type/eto.forms.control/visible.md), [VisualParent](https://eto.picoe.ca/api/type/eto.forms.control/visualparent.md), [Width](https://eto.picoe.ca/api/type/eto.forms.control/width.md), [DragDrop](https://eto.picoe.ca/api/type/eto.forms.control/dragdrop.md), [DragEnd](https://eto.picoe.ca/api/type/eto.forms.control/dragend.md), [DragEnter](https://eto.picoe.ca/api/type/eto.forms.control/dragenter.md), [DragLeave](https://eto.picoe.ca/api/type/eto.forms.control/dragleave.md), [DragOver](https://eto.picoe.ca/api/type/eto.forms.control/dragover.md), [EnabledChanged](https://eto.picoe.ca/api/type/eto.forms.control/enabledchanged.md), [GotFocus](https://eto.picoe.ca/api/type/eto.forms.control/gotfocus.md), [KeyDown](https://eto.picoe.ca/api/type/eto.forms.control/keydown.md), [KeyUp](https://eto.picoe.ca/api/type/eto.forms.control/keyup.md), [Load](https://eto.picoe.ca/api/type/eto.forms.control/load.md), [LoadComplete](https://eto.picoe.ca/api/type/eto.forms.control/loadcomplete.md), [LostFocus](https://eto.picoe.ca/api/type/eto.forms.control/lostfocus.md), [MouseDoubleClick](https://eto.picoe.ca/api/type/eto.forms.control/mousedoubleclick.md), [MouseDown](https://eto.picoe.ca/api/type/eto.forms.control/mousedown.md), [MouseEnter](https://eto.picoe.ca/api/type/eto.forms.control/mouseenter.md), [MouseLeave](https://eto.picoe.ca/api/type/eto.forms.control/mouseleave.md), [MouseMove](https://eto.picoe.ca/api/type/eto.forms.control/mousemove.md), [MouseUp](https://eto.picoe.ca/api/type/eto.forms.control/mouseup.md), [MouseWheel](https://eto.picoe.ca/api/type/eto.forms.control/mousewheel.md), [PreLoad](https://eto.picoe.ca/api/type/eto.forms.control/preload.md), [Shown](https://eto.picoe.ca/api/type/eto.forms.control/shown.md), [SizeChanged](https://eto.picoe.ca/api/type/eto.forms.control/sizechanged.md), [TextInput](https://eto.picoe.ca/api/type/eto.forms.control/textinput.md), [ThemeChanged](https://eto.picoe.ca/api/type/eto.forms.control/themechanged.md), [UnLoad](https://eto.picoe.ca/api/type/eto.forms.control/unload.md), [AttachNative](https://eto.picoe.ca/api/type/eto.forms.control/attachnative.md), [CaptureMouse](https://eto.picoe.ca/api/type/eto.forms.control/capturemouse.md), [Detach](https://eto.picoe.ca/api/type/eto.forms.control/detach.md), [DetachNative](https://eto.picoe.ca/api/type/eto.forms.control/detachnative.md), [Dispose](https://eto.picoe.ca/api/type/eto.forms.control/dispose.md), [DoDragDrop](https://eto.picoe.ca/api/type/eto.forms.control/dodragdrop.md), [FindParent](https://eto.picoe.ca/api/type/eto.forms.control/findparent.md), [Focus](https://eto.picoe.ca/api/type/eto.forms.control/focus.md), [GetCallback](https://eto.picoe.ca/api/type/eto.forms.control/getcallback.md), [GetPreferredSize](https://eto.picoe.ca/api/type/eto.forms.control/getpreferredsize.md), [Invalidate](https://eto.picoe.ca/api/type/eto.forms.control/invalidate.md), [MapPlatformCommand](https://eto.picoe.ca/api/type/eto.forms.control/mapplatformcommand.md), [OnApplyCascadingStyles](https://eto.picoe.ca/api/type/eto.forms.control/onapplycascadingstyles.md), [OnDragDrop](https://eto.picoe.ca/api/type/eto.forms.control/ondragdrop.md), [OnDragEnd](https://eto.picoe.ca/api/type/eto.forms.control/ondragend.md), [OnDragEnter](https://eto.picoe.ca/api/type/eto.forms.control/ondragenter.md), [OnDragLeave](https://eto.picoe.ca/api/type/eto.forms.control/ondragleave.md), [OnDragOver](https://eto.picoe.ca/api/type/eto.forms.control/ondragover.md), [OnEnabledChanged](https://eto.picoe.ca/api/type/eto.forms.control/onenabledchanged.md), [OnGotFocus](https://eto.picoe.ca/api/type/eto.forms.control/ongotfocus.md), [OnKeyDown](https://eto.picoe.ca/api/type/eto.forms.control/onkeydown.md), [OnKeyUp](https://eto.picoe.ca/api/type/eto.forms.control/onkeyup.md), [OnLostFocus](https://eto.picoe.ca/api/type/eto.forms.control/onlostfocus.md), [OnMouseDoubleClick](https://eto.picoe.ca/api/type/eto.forms.control/onmousedoubleclick.md), [OnMouseDown](https://eto.picoe.ca/api/type/eto.forms.control/onmousedown.md), [OnMouseEnter](https://eto.picoe.ca/api/type/eto.forms.control/onmouseenter.md), [OnMouseLeave](https://eto.picoe.ca/api/type/eto.forms.control/onmouseleave.md), [OnMouseMove](https://eto.picoe.ca/api/type/eto.forms.control/onmousemove.md), [OnMouseUp](https://eto.picoe.ca/api/type/eto.forms.control/onmouseup.md), [OnMouseWheel](https://eto.picoe.ca/api/type/eto.forms.control/onmousewheel.md), [OnShown](https://eto.picoe.ca/api/type/eto.forms.control/onshown.md), [OnSizeChanged](https://eto.picoe.ca/api/type/eto.forms.control/onsizechanged.md), [OnTextInput](https://eto.picoe.ca/api/type/eto.forms.control/ontextinput.md), [OnThemeChanged](https://eto.picoe.ca/api/type/eto.forms.control/onthemechanged.md), [PointFromScreen](https://eto.picoe.ca/api/type/eto.forms.control/pointfromscreen.md), [PointToScreen](https://eto.picoe.ca/api/type/eto.forms.control/pointtoscreen.md), [Print](https://eto.picoe.ca/api/type/eto.forms.control/print.md), [RectangleFromScreen](https://eto.picoe.ca/api/type/eto.forms.control/rectanglefromscreen.md), [RectangleToScreen](https://eto.picoe.ca/api/type/eto.forms.control/rectangletoscreen.md), [ReleaseMouseCapture](https://eto.picoe.ca/api/type/eto.forms.control/releasemousecapture.md), [ResumeLayout](https://eto.picoe.ca/api/type/eto.forms.control/resumelayout.md), [SuspendLayout](https://eto.picoe.ca/api/type/eto.forms.control/suspendlayout.md), [TriggerStyleChanged](https://eto.picoe.ca/api/type/eto.forms.control/triggerstylechanged.md), [UpdateLayout](https://eto.picoe.ca/api/type/eto.forms.control/updatelayout.md)
- From [BindableWidget](https://eto.picoe.ca/api/type/eto.forms.bindablewidget.md): [Bindings](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/bindings.md), [DataContext](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/datacontext.md), [IsDataContextChanging](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/isdatacontextchanging.md), [Parents](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/parents.md), [DataContextChanged](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/datacontextchanged.md), [OnDataContextChanged](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/ondatacontextchanged.md), [Unbind](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/unbind.md), [UpdateBindings](https://eto.picoe.ca/api/type/eto.forms.bindablewidget/updatebindings.md)
- From [Widget](https://eto.picoe.ca/api/type/eto.widget.md): [ControlObject](https://eto.picoe.ca/api/type/eto.widget/controlobject.md), [ID](https://eto.picoe.ca/api/type/eto.widget/id.md), [IsDisposed](https://eto.picoe.ca/api/type/eto.widget/isdisposed.md), [NativeHandle](https://eto.picoe.ca/api/type/eto.widget/nativehandle.md), [Platform](https://eto.picoe.ca/api/type/eto.widget/platform.md), [Properties](https://eto.picoe.ca/api/type/eto.widget/properties.md), [Style](https://eto.picoe.ca/api/type/eto.widget/style.md), [StyleChanged](https://eto.picoe.ca/api/type/eto.widget/stylechanged.md), [Dispose](https://eto.picoe.ca/api/type/eto.widget/dispose.md), [Initialize](https://eto.picoe.ca/api/type/eto.widget/initialize.md), [ToString](https://eto.picoe.ca/api/type/eto.widget/tostring.md)
