Solved

Right-to-Left reading order TextBox

Posted on 2009-04-13
8
1,400 Views
Last Modified: 2013-12-17
How to make the textboxes at my form to be from right to left (start from the right).

Programmatically without do this by shortcuts ALT + Right SHIFT Or without Right Click choose Right-to-Left reading order

0
Comment
Question by:Rewaya
  • 4
  • 4
8 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24130317
If I'm understanding you correctly, you want to set the RightToLeft property for all the textboxes in the form.
foreach (Control child in this.Controls){

  if (! child is TextBox) continue;

  ((TextBox)child).RightToLeft = RightToLeft.Yes;

}

Open in new window

0
 

Author Comment

by:Rewaya
ID: 24135599

Right-to-Left property doesn't achieve what I need,
 
I mean cursor direction, if you try to press Alt+Shift at text box and notice how the cursors changes.
This exactly what I mean. Right-to-left reading order used for Middle East language like Arabic   .
 
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24141595
Can you explain why the RightToLeft property doesn't achive what you need. This property is there solely for Middle & Far Eastern languages, and is the exact same as Chosing "Right to Left Reading order" from the context menu.

Is it possible that the code I gave you isn't doing what you need because it's not changing the properties recurs
SetRightToLeft(this, RightToLeft.Yes);
 

    private void SetRightToLeft(Control container, RightToLeft value) {

      foreach (Control child in container.Controls) {

        if (child.HasChildren) {

          SetRightToLeft(child, value);

        }

        if (child is TextBox) {

          ((TextBox)child).RightToLeft = value;

        }

      }

    }

Open in new window

0
 

Author Comment

by:Rewaya
ID: 24145682

Right to left property just move the cursor to start writing from right  but I want to change writing language of keyboard through code not the direction of writing.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 15

Expert Comment

by:oobayly
ID: 24146142
Now I understand. To be fair you never once mentioned language in any of your posts, as I don't have multiple languages installed so I'm not used to the Left Alt + Shift shortcut to change the langauge.

The function below shows how the input language can be changed. Every time it is called, it gets the next language in the list.
    private void SelectNextInputLanguage() {

      int index = InputLanguage.InstalledInputLanguages.IndexOf(InputLanguage.CurrentInputLanguage);

      if (index == InputLanguage.InstalledInputLanguages.Count - 1) {

        index = 0;

      } else {

        index++;

      }

      InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[index];

    }

Open in new window

0
 

Author Comment

by:Rewaya
ID: 24148725

Nice, but in some cases the index of language different from computer to another
I want to change it throw name not index.
There a way to do that but I want another one more efficient
 

int LanguageCount=InputLanguage.InstalledInputLanguages.Count;

            for(int i=0;i<LanguageCount;i++)

                if (InputLanguage.InstalledInputLanguages[i].LayoutName == "Arabic (101)")

                {

                    InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[i]; break;

                }

Open in new window

0
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24148864
How many languages do you have on your machine? If you're worried about efficiency, then put a break statement after setting the CurrentInputLanguage. A least then you're not looping through all languages even though you set the desired one.

Striving for efficiency is great, but I can't believe looping through a handful of items is going to be a bottle neck in your app.
0
 

Author Comment

by:Rewaya
ID: 24149326

OK Mr.oobayly
Thanks for your information.  
I am already put break after setting the CurrentInputLanguage...
 
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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

15 Experts available now in Live!

Get 1:1 Help Now