c# winform做程序的语言切换,切换不了
本人刚学不久help
想选择单选按钮,就自动切换语言。但是出现问题:每次选择单选按钮,如果输入框有文字会被清除,而且并不能转换语言
MainForm.cs
private void ApplyResource()
{
ComponentResourceManager resource = new ComponentResourceManager(typeof(MainForm));
foreach (Control item in this.Controls)
{
if (item != null)
{
resource.ApplyResources(item, item.Name);
}
}
this.ResumeLayout(false);
this.PerformLayout();
resource.ApplyResources(this, "$this");
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
this.ApplyResource();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
this.ApplyResource();
}