Moodz_Yyq 2023-09-04 17:03 采纳率: 33.3%
浏览 23

c# winform做程序的语言切换,切换不了

c# winform做程序的语言切换,切换不了
本人刚学不久help
想选择单选按钮,就自动切换语言。但是出现问题:每次选择单选按钮,如果输入框有文字会被清除,而且并不能转换语言

img

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();
}

img

  • 写回答

2条回答 默认 最新

  • 我是苏苏 2023-09-04 17:18
    关注

    我理解你的意思,我大概分享一下思路:
    你可以设置默认是中文,打开桌面程序的时候默认翻译一次中文
    然后点击英文按钮,再触发翻译英文;如此就能实现你想要的效果了;

    评论

报告相同问题?

问题事件

  • 修改了问题 9月4日
  • 创建了问题 9月4日