Skip to main content

Converting a Regular Layout of Controls to an XtraLayoutControl

  • 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.

LayoutConverter_Tasks

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:

  • GroupBox and GroupControl objects are converted to LayoutControlGroup objects. The contents of these controls are also processed and converted accordingly.
  • TabControl and XtraTabControl objects are converted to TabbedControlGroup objects. The contents of these controls are also processed and converted accordingly.
  • Panel and PanelControl objects are converted to LayoutControlItem objects. The contents of these containers are not processed.
  • If a label (Label or LabelControl) is displayed on the left of a control, the label and the control will be represented by a single LayoutControlItem object.

    During the conversion, the label object’s properties (except its default text) are lost. The label’s localized text is also lost.

  • Other objects are converted to LayoutControlItem objects.

‘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.