Solved

interface mirroring of bilingual windows forms

Posted on 2006-07-12
4
341 Views
Last Modified: 2010-05-18
hi experts..

I have a windows form which is bilingual and based on the language the user selects the layout of the form should change. I change the direction property of the form from "left to right" to "right to left" but it changes the layout of each control.. i need the whole form to mirror itself so it moves the controls that are on the left side of the form,to the right side and vice versa.. based on the language.
I'm using .NET 1.1
Is there an effective way to accomplish this using VB.NET..??
0
Comment
Question by:mirmansoor
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
nickhoggard earned 500 total points
ID: 17088790
Hi,

Not sure if there is an easier way built into .NET, but the following seemed to work in a quick test project I created:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each ctrl As Control In Me.Controls
            SwitchControls(ctrl)
        Next
    End Sub

    Private Sub SwitchControls(ByVal ctrl As Control)
        For Each objControl As Control In ctrl.Controls
            SwitchControls(objControl)
        Next
        ctrl.Left = ctrl.Parent.ClientRectangle.Width - ctrl.Left - ctrl.Width
    End Sub

The general idea is to recursively check all controls on the form, and mirror them to the opposite side.

Hope this helps

Cheers

Nick
0
 
LVL 5

Expert Comment

by:nickhoggard
ID: 17088798
Just to followup, I wrote that in .NET 2.0, but I dont think there is anything there that is not in 1.1.  

Nick
0
 

Expert Comment

by:Mascolo
ID: 17089411
Using .NET 2.0 also provides a better solution which may be worth the cost in upgrading to against the amount of time you potentially need to write something similar to above. That is in .NET 2.0 you can set a form or container RightToLeft property which then alters all child controls RightToLeft property too.

The following code alters a whole form (and all its labels, buttons etc) when a button is pressed

             frmMain.RightToLeft = Windows.Forms.RightToLeft.Yes

You can also pass '...+ MsgBoxStyle.MsgBoxRtlReading) into the MessageboxStyle so that dialogs also behave in this manor too. This also includes swapping the control boxes and form captions too, all in literally one line of code!
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 17089642
I would imagine that the culture properties (you *are* using culture for you localization, right?) would include a RightToLeft indicator as well....

Specifically, CultureInfo.TextInfo.IsRightToLeft will tell you how you need to display the text.

As Mascolo pointed out, however, the control RightToLeft property in 2.0 specific.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question