Solved

interface mirroring of bilingual windows forms

Posted on 2006-07-12
4
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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