Hindi Input in textbox c# application

半城伤御伤魂 提交于 2020-01-06 19:41:41

问题


Is their any way to get Hindi input in a textbox in a c# application . I am just trying a simple I am bit new to C# and stackoverflow community . SO let me know if i have missed something while asking question


回答1:


Finally i got a answer for it and posting it for Your comment , reviews and help who needs same. I just added a checkbox and below is the code .

private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (checkBox1.Checked)
        {
            textBox1.Font = new Font("Mangal", 10);
            textBox2.Font = new Font("Mangal", 10);
            ToHindiInput();


        }
        else 
        {
            textBox1.Font = new Font("Times New Roman", 10);
            textBox2.Font = new Font("Times New Roman", 10);
            ToEnglishInput();
        }
    }
public void ToEnglishInput()
    {
        string CName = "";
        foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
        {
            CName = lang.Culture.EnglishName.ToString();
            if (CName.StartsWith("English"))
            {
                InputLanguage.CurrentInputLanguage = lang;
            }
        }

    }
    public void ToHindiInput()
    {
        string CName = "";
        foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
        {
            CName = lang.Culture.EnglishName.ToString();

            if (CName.StartsWith("Hindi"))
            {
                InputLanguage.CurrentInputLanguage = lang;
            }
        }

    }

For InputLanguage to work You need to have that language installed in Your Machine . Can be done by going to Region and language setting -> 3rd tab and install Hindi language .

Note: 1. Your Keyboard layout will for other task also change
So don't forget to call ToEnglishInput() on closing of the form .

2.Also You can use OnScreen keyboard to input if You feel it difficult to input. 3. The same approach can be implemented to for multiple languages.

Plz Vote Up if you find answer satifactory . Suggestion are always welcome. Happy Coding. :-)



来源:https://stackoverflow.com/questions/26382803/hindi-input-in-textbox-c-sharp-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!