Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Right-to-Left reading order TextBox

Posted on 2009-04-13
8
Medium Priority
?
1,413 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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