TX Words: Right to Left

Text Control supports right to left text rendering for languages such as Arabic or Hebrew. Most often, users working with "RTL languages", also prefer an application view with a right-to-left orientation. This sample shows how to implement a button that restarts the program in the opposite application view.

The source code for this example is contained in the following directories:

  • %USERPROFILE%\Documents\TX Text Control 32.0.NET for Windows Forms\CSharp\TX Words\Right To Left
  • %USERPROFILE%\Documents\TX Text Control 32.0.NET for Windows Forms\VB.NET\TX Words\Right To Left

Using the Sample

To change the application view, click the Right to Left button. It opens a message box where the user can confirm the view change by restarting the program. After the application is restarted, the orientation of the sample is changed to right to left.


The Code Behind

When clicking the Right to Left button, the requested layout will be saved as Settings property value before the application is restarted.

private void RightToLeftFormLayout_Click(object sender, System.EventArgs e) {
        bool bIsRightToLeft = (bool)(sender as RibbonButton).Tag;
        if (SaveDirtyDocumentBeforeReset(bIsRightToLeft)) {
                Properties.Settings.Default.RightToLeft = bIsRightToLeft ? RightToLeft.No : RightToLeft.Yes;
Private Sub RightToLeftFormLayout_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim bIsRightToLeft As Boolean = CBool(TryCast(sender, RibbonButton).Tag)
        If SaveDirtyDocumentBeforeReset(bIsRightToLeft) Then
                My.Settings.Default.RightToLeft = If(bIsRightToLeft, RightToLeft.No, RightToLeft.Yes)
                Call Application.Restart()
        End If
End Sub

After that, this layout is loaded when the application is initialized for restart.

public MainWindow() {
        // Get and set saved application settings.
Public Sub New()
        ' Add an unhandled exception handler
        Dim currentDomain As AppDomain = AppDomain.CurrentDomain
        AddHandler currentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException

        ' Get and set saved application settings.
End Sub

It updates both the RightToLeftLayout property value of the application and that of the ribbon.

private void LoadRightToLeftSettings() {
        this.RightToLeftLayout =
        m_rbnRibbon.RightToLeftLayout = (this.RightToLeft = Properties.Settings.Default.RightToLeft) == RightToLeft.Yes;
Private Sub LoadRightToLeftSettings()
        RightToLeftLayout = CSharpImpl.Assign(m_rbnRibbon.RightToLeftLayout, CSharpImpl.Assign(RightToLeft, My.Settings.Default.RightToLeft) = RightToLeft.Yes)
End Sub
End Sub