Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

interface mirroring of bilingual windows forms

Posted on 2006-07-12
4
Medium Priority
?
348 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

647 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