I got a question from a previous post, about when should we set RightToLeftLayout, and RightToLeft in the code. His scenario is as follows:
He has a multi lingual Windows Forms application. In the case of Arabic, he sets RightToLeft at runtime, depending on a value in his resources. If his UI is English then there is no need to set RightToLeft.
His question is:
When should I set RightToLeftLayout and RightToLeft? I tried to set them on Form.Load but the Form was flickering and it didn’t look good.
The solution is:
First, for RightToLeftLayout: if you decide to set RightToLeftLayout to true, you can set it for any language since it doesn’t have effect unless RightToLeft.Yes is set. So please set RightToLeftLayout at design time, for needed controls.
Second, for RightToLeft: you should set it in the Form constructor and not the Form.Load. Follow these easy steps:
1) [In case of VB] Overload your form, “New” sub:
2) After initializing the component set the RightToLeft property.
Your code should look like this:
Public Sub New()
‘ This call is required by the designer.
‘ Add any initialization after the InitializeComponent() call.
‘Not needed Me.RightToLeftLayout = True
Me.RightToLeft = Windows.Forms.RightToLeft.Yes
// This call is required by the designer.
// Add any initialization after the InitializeComponent() call.
// Not needed Me.RightToLeftLayout = True
this.RightToLeft = RightToLeft.Yes;