窗体中有一个richtextbox,combobox,button.
相应代码如下:
private void Form1_Load(object sender, System.EventArgs e)
{
InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;
foreach ( InputLanguage il in ilc )
{
comboBox1.Items.Add( il.LayoutName );
}
comboBox1.SelectedIndex = InputLanguage.InstalledInputLanguages.IndexOf(InputLanguage.CurrentInputLanguage ) ;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
InputLanguage il = InputLanguage.InstalledInputLanguages[ comboBox1.SelectedIndex ];
InputLanguage.CurrentInputLanguage = il;
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
在原文件中,还有这样的一些代码:
private void ChangeInput(object sender, System.Windows.Forms.InputLanguageChangedEventArgs e)
{
InputLanguage il = e.InputLanguage ;
int i = InputLanguage.InstalledInputLanguages.IndexOf( il );
if( i >= 0 && i < InputLanguage.InstalledInputLanguages.Count )
{
comboBox1.SelectedIndex = i ;
}
}
有没有都是一样的运行结果,不知道起到了什么作用?
大家说说看。