1

在我的 Windows 申请表 (c#) 上,我有阿拉伯文和英文文本框。对于阿拉伯语文本框,我想在不按 (alt + shift) 的情况下自动将我的语言转换为阿拉伯语。我在互联网上找到了这个解决方案,并在 TextBox Enter 上实现了它

 private void TextArabs_Enter(object sender, EventArgs e)
        {              
            System.Globalization.CultureInfo TypeOfLanguage = new System.Globalization.CultureInfo("ar");
            InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(TypeOfLanguage);   

        }

但是当我在文本框中输入时,它仍然输入英文字母而不是阿拉伯语。我应该怎么办

4

1 回答 1

3

你可以这样使用:

private void TextArabs_Enter(object sender, EventArgs e)
        {              
            InputLanguage.CurrentInputLanguage =
                InputLanguage.InstalledInputLanguages[1];   

        }

0:安装在系统上的语言 1 1:安装在系统上的
语言 2,...

更新 :

 InputLanguage arabic;
        InputLanguage english;
        private void Form1_Load(object sender, EventArgs e)
        {
            arabic = InputLanguage.CurrentInputLanguage;
            english = InputLanguage.CurrentInputLanguage;
            int count = InputLanguage.InstalledInputLanguages.Count;
            for (int i = 0; i <= count - 1; i++)
            {
                if (InputLanguage.InstalledInputLanguages[i].LayoutName.Contains("Arabic"))
                {
                    arabic = InputLanguage.InstalledInputLanguages[i];
                }
                if (InputLanguage.InstalledInputLanguages[i].LayoutName.Contains("English"))
                {
                    english = InputLanguage.InstalledInputLanguages[i];
                }
            }
        }
        private void txtArabic_Enter(object sender, EventArgs e)
        {
            InputLanguage.CurrentInputLanguage = arabic;
        }

        private void txtEnglish_Enter(object sender, EventArgs e)
        {
            InputLanguage.CurrentInputLanguage = english;
        }
于 2013-06-22T07:32:58.277 回答