Back to Devexpress

Converting a Regular Layout of Controls to an XtraLayoutControl

windowsforms-3271-controls-and-libraries-form-layout-managers-layout-and-data-layout-controls-layout-control-converting-a-regular-layout-of-controls-to-an-xtralayoutcontrol.md

latest3.6 KB
Original Source

Converting a Regular Layout of Controls to an XtraLayoutControl

  • Jan 23, 2019
  • 3 minutes to read

With a few mouse clicks, you can easily convert an existing regular layout of controls to a Layout Control, and vice versa. All you need to do is to place a LayoutConverter component on your form (or UserControl), and then use its commands to perform a conversion. The following image shows a LayoutConverter’s commands.

The LayoutConverter component only provides design-time functionality. It serves no purpose at runtime. So, after converting a layout you can freely delete the LayoutConveter component.

‘Convert regular layout to XtraLayout’ Command

When choosing this command, the LayoutConverter first asks you to choose the container that displays the controls to be converted to a Layout Control. The following containers are supported:

  • ContainerControl descendants (for instance, Form and UserControl), except the PropertyGrid and SplitContainer.
  • Panel controls and their descendants
  • GroupBox controls and their descendants
  • XtraPanel descendants (for instance, PanelControl and GroupControl), except the SplitContainerControl.

Note

Empty containers cannot be selected.

After selecting a container, all its controls are moved to a new LayoutControl. During the conversion, the LayoutConveter tries to retain the relative distances between controls in the output layout as close as possible to the original layout. However, due to control arrangement rules that the Layout Control follows, specific regular layouts may not be exactly reproduced using a LayoutControl.

The selected container’s children are converted as follows:

‘Convert XtraLayout to regular layout’ Command

This command does the opposite operation - it moves controls from an existing Layout Control to the form (or UserControl). First, you’re asked to select a LayoutControl control to be converted to a regular layout. After selecting a LayoutControl, all its controls are moved to the current form (or UserControl) and then the LayoutControl is destroyed. During this kind of conversion, the positions of controls in the output layout will be the same as in the original layout.