Solved

Right-to-Left reading order TextBox

Posted on 2009-04-13
8
1,398 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now