Solved

Right-to-Left reading order TextBox

Posted on 2009-04-13
8
1,405 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
[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
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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