coder3521
coder3521

Reputation: 2646

Hindi Input in textbox c# application

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

Upvotes: 1

Views: 6836

Answers (1)

coder3521
coder3521

Reputation: 2646

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. :-)

Upvotes: 3

Related Questions