mayank.karki
mayank.karki

Reputation: 748

change textbox input language on change of app language

I am working on a metro app which provides a change language option in app. I want that on change of language textbox input language also get change. and it should not depends on system language.

Upvotes: 0

Views: 590

Answers (2)

Alireza Ali
Alireza Ali

Reputation: 43

I use these codes: First of all you must find the name of the culture language you want. method "GetInutLanguageByName" will return the language that you requested Then you will check whether you installed the requested language or not, if yes then return the requested language. Then change the input language very easy...

private static InputLanguage GetInutLanguageByName(string layOut)
    {
        foreach (InputLanguage lng in InputLanguage.InstalledInputLanguages)
        {
            if (lng.Culture.DisplayName == layOut)
            {
                return lng;
            }
        }
        return null;

    }

private void SetKeyboardLayout(InputLanguage Layout)
    {
        InputLanguage.CurrentInputLanguage = Layout;
    }

private void FirstNameTextBox_Enter(object sender, EventArgs e)
    {

        SetKeyboardLayout(GetInutLanguageByName("Persian"));

    }

Upvotes: 1

Solat Ali
Solat Ali

Reputation: 39

Firstly, you need to make sure that the language you want is installed in OS, and it is in the list of INSTALLED INPUT LANGUAGES (check the language bar in control panel under Language and Regional Settings).. If its not in language bar, add it.. e.g. you want to change app language to "FRENCH".. you would need to create a new resource file for every language you want to change in app, and then change the current thread's Culture Property.. Are you familiar with resources file (.resx) and Culture Info Class??

Upvotes: 0

Related Questions