110,499
社区成员
发帖
与我相关
我的任务
分享
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="language" />
</assemblyBinding>
</runtime>
private void button10_Click(object sender, EventArgs e)
{
//切换到中文
//使用资源文件 强名访问的方式,支持多语言系统
Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
CultureRes.ApplyResources(this); //改变设计期控件内容
tbAuthor.Text = CultureRes.Author; //改变动态内容,且使用强名称调用
MessageBox.Show(String.Format(CultureRes.判断某字段不能为空_Arg0, CultureRes.商品名称));
}
private void button11_Click(object sender, EventArgs e)
{
//切换到美国英语
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
CultureRes.ApplyResources(this);
tbAuthor.Text = CultureRes.Author;
MessageBox.Show(String.Format(CultureRes.判断某字段不能为空_Arg0, CultureRes.商品名称));
}
/// <summary>
/// 为窗体更新资源文件内容
/// </summary>
/// <param name="form"></param>
public static void ApplyResources(Form form)
{
ComponentResourceManager rm = new System.ComponentModel.ComponentResourceManager(form.GetType());
foreach (Control ctl in form.Controls)
{
rm.ApplyResources(ctl, ctl.Name);
form.ResumeLayout(false);
form.PerformLayout();
}
//Caption
rm.ApplyResources(form, "$this");
}