Solved

Right-to-Left reading order TextBox

Posted on 2009-04-13
8
1,401 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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
 
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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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