考慮到程序的國際化需求,需要為程序設置多語言界面。
1,新建一個資源文件,名字可以是對應界面+語言代碼(MainForm.zh-CN)。這樣資源文件就會自動添加到對應界面下面。
2,更改界面屬性Localizable為Ture
3,調用相關的資源文件,為相關控件賦值
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
if (form != null)
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(formType);
resources.ApplyResources(form, "MainForm");
//AppLang(form, resources);
}