Solved

interface mirroring of bilingual windows forms

Posted on 2006-07-12
4
338 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now