Winforms Arabic Input text box

后端 未结 1 643
广开言路
广开言路 2021-01-24 09:07

on my windows application form (c#) , i have arabic and english text boxes. for Arabic text boxes i want to automatically shift my language to arabic without presshing (alt + sh

相关标签:
1条回答
  • 2021-01-24 09:43

    you can use this way :

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

    0: Language 1 that installed on your system
    1: Language 2 that installed on your system ,...

    Updated :

     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;
            }
    
    0 讨论(0)
提交回复
热议问题