我想从语言栏中获取当前的键盘语言:
我想实时做到这一点。怎么样?
编辑:
表格加载:
Timer1.Start()
Public Sub MyCurrentInputLanguage()
Dim myCurrentLanguage As InputLanguage = InputLanguage.CurrentInputLanguage
Me.Text = "Current input language is: " & _
myCurrentLanguage.Culture.EnglishName
End Sub
计时器:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MyCurrentInputLanguage()
end sub
当用户按“Alt + Shift”时,如何更新文本框?
答案 0 :(得分:1)
使用InputLanguage.CurrentInputLanguage
。 MSDN上的链接给出了这个例子:
CurrLang = InputLanguage.CurrentInputLanguage
以下是InputLanguage
的详细信息。
您可以使用Form.InputLanguageChanged
事件在运行时检测更改(不使用计时器)。 (引用的MSDN链接示例。)
Private Sub Form1_InputLanguageChanged(sender as Object, e as InputLanguageChangedEventArgs) _
Handles Form1.InputLanguageChanged
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "InputLanguage", e.InputLanguage)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Culture", e.Culture)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "CharSet", e.CharSet)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"InputLanguageChanged Event")
End Sub
(感谢HansPassant提供的信息。)