我想更改語言,但編譯時會彈出一個異常。它說在C#winform運行時更改語言
「找不到適合指定區域性或 中性文化的任何資源。確保‘System.Type.resources’正確 嵌入或鏈接到程序集‘在編譯時mscorlib程序’,或 所需的所有衛星組件都可加載並完全簽名。「
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "English")
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("En");
ChangeLanguage("En");
}
else if (comboBox1.SelectedItem.ToString() == "German")
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("De");
ChangeLanguage("De");
}
}
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Type));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
有什麼建議?
在comboBox1_SelectedIndexChanged中放入Console.Writeline(comboBox1.SelectedItem.ToString());所以你可以看到錯誤 – Tinwor
男人這是要解決什麼...... – franzp
我知道,但我想知道,如果在窗體中調用comboBox1_SelectedIndexChanged – Tinwor