Layout Controls Properly without Re-arranging them Manually

I had a question last week from a customer who wanted to display a right-to-left WinForm but doesn't want to manually rearrange the items from right-to-left. What would be the recommended way to obtain the correct layout without rearranging the items?

The recommended solution is to use the new *LayoutPanels (TableLayoutPanel and FlowLayoutPanel) and SplitContainer instead of using the Form and Panels to host your controls. For example, create a Form, add a TablelayoutPanel and dock fill to the Form, and then add the controls on the Form.

The TableLayoutPanel supports rtl. Simply, set RightToLeft=Yes and the columns would rearrange from right-to-left. This means, the first column would start from the right and the next column is on its left.

Like the TableLayoutPanel , the FlowLayoutPanel also supports rtl. Simply set RightToLeft =Yes and the items would flow from right-to-left.

In the case of vertical panels, when you set the SplitContainer.RightToLeft=Yes. The Panels are reversed. The First panel is place on the right while the second panel is placed on the left. However, the contents of each panel don't flow from right-to-left. To achieve this you can dock a TableLayoutPanel or a FlowLayoutPanel into these SplitContainer's panels.

More info about these *LayoutPanels and RTL is available, at this useful article

Another solution that is not really recommended, to rearrange the controls in the Form is to set RightToLeftLayout = true. This has its limitations since the dev won't be able to set background and opacity .. etc. Check the remarks section of Form.RightToLeftLayout Property (System.Windows.Forms).

I hope this helps!

Skip to main content