• <bdo id='N1PEe'></bdo><ul id='N1PEe'></ul>
      1. <i id='N1PEe'><tr id='N1PEe'><dt id='N1PEe'><q id='N1PEe'><span id='N1PEe'><b id='N1PEe'><form id='N1PEe'><ins id='N1PEe'></ins><ul id='N1PEe'></ul><sub id='N1PEe'></sub></form><legend id='N1PEe'></legend><bdo id='N1PEe'><pre id='N1PEe'><center id='N1PEe'></center></pre></bdo></b><th id='N1PEe'></th></span></q></dt></tr></i><div id='N1PEe'><tfoot id='N1PEe'></tfoot><dl id='N1PEe'><fieldset id='N1PEe'></fieldset></dl></div>
        <legend id='N1PEe'><style id='N1PEe'><dir id='N1PEe'><q id='N1PEe'></q></dir></style></legend>
        <tfoot id='N1PEe'></tfoot>

        <small id='N1PEe'></small><noframes id='N1PEe'>

        如何在运行时更改 WinForms 应用程序的文化

        时间:2023-08-27
      2. <small id='pDux2'></small><noframes id='pDux2'>

            <tbody id='pDux2'></tbody>
            <bdo id='pDux2'></bdo><ul id='pDux2'></ul>

          • <tfoot id='pDux2'></tfoot>
            <i id='pDux2'><tr id='pDux2'><dt id='pDux2'><q id='pDux2'><span id='pDux2'><b id='pDux2'><form id='pDux2'><ins id='pDux2'></ins><ul id='pDux2'></ul><sub id='pDux2'></sub></form><legend id='pDux2'></legend><bdo id='pDux2'><pre id='pDux2'><center id='pDux2'></center></pre></bdo></b><th id='pDux2'></th></span></q></dt></tr></i><div id='pDux2'><tfoot id='pDux2'></tfoot><dl id='pDux2'><fieldset id='pDux2'></fieldset></dl></div>
            <legend id='pDux2'><style id='pDux2'><dir id='pDux2'><q id='pDux2'></q></dir></style></legend>
                  本文介绍了如何在运行时更改 WinForms 应用程序的文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经用 C# 创建了 Windows 窗体程序.我在本地化方面遇到了一些问题.我有两种语言的资源文件(一种是英语,另一种是法语).我想在运行时单击每个语言按钮并更改语言.

                  I have created Windows Form Program in C#. I have some problems with localization. I have resource files in 2 languages(one is for english and another is for french). I want to click each language button and change language at runtime.

                  但是当我点击按钮时,它不起作用.我正在使用此代码.

                  But when i am clicking on button, it doesn't work. i am using this code.

                  private void btnfrench_Click(object sender, EventArgs e)
                  {
                      getlanguage("fr-FR");
                  }
                  
                  private void getlanguage(string lan)
                  {
                      foreach (Control c in this.Controls)
                      {
                          ComponentResourceManager cmp = 
                              new ComponentResourceManager(typeof(BanksForm));
                          cmp.ApplyResources(c, c.Name, new CultureInfo(lan));
                      }
                  }
                  

                  请大家帮忙解决这个问题......

                  would any pls help on this......

                  非常感谢....

                  推荐答案

                  成功了:

                  private void button1_Click(object sender, EventArgs e)
                  {
                      System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-BE");
                      ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
                      resources.ApplyResources(this, "$this");
                      applyResources(resources, this.Controls);
                  }
                  
                  private void applyResources(ComponentResourceManager resources, Control.ControlCollection ctls)
                  {
                      foreach (Control ctl in ctls)
                      {
                          resources.ApplyResources(ctl, ctl.Name);
                          applyResources(resources, ctl.Controls);
                      }
                  }
                  

                  请小心避免添加这种没人会使用的口哨.它充其量只是一个演示功能,实际上用户不会即时更改他们的母语.

                  Be careful to avoid adding whistles like this that nobody will ever use. It at best is a demo feature, in practice users don't change their native language on-the-fly.

                  这篇关于如何在运行时更改 WinForms 应用程序的文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 WPF 中设置和更改区域性 下一篇:JSON序列化时如何本地化?

                  相关文章

                  最新文章

                1. <small id='hGlxt'></small><noframes id='hGlxt'>

                      <bdo id='hGlxt'></bdo><ul id='hGlxt'></ul>
                    <i id='hGlxt'><tr id='hGlxt'><dt id='hGlxt'><q id='hGlxt'><span id='hGlxt'><b id='hGlxt'><form id='hGlxt'><ins id='hGlxt'></ins><ul id='hGlxt'></ul><sub id='hGlxt'></sub></form><legend id='hGlxt'></legend><bdo id='hGlxt'><pre id='hGlxt'><center id='hGlxt'></center></pre></bdo></b><th id='hGlxt'></th></span></q></dt></tr></i><div id='hGlxt'><tfoot id='hGlxt'></tfoot><dl id='hGlxt'><fieldset id='hGlxt'></fieldset></dl></div>

                      <legend id='hGlxt'><style id='hGlxt'><dir id='hGlxt'><q id='hGlxt'></q></dir></style></legend>
                    1. <tfoot id='hGlxt'></tfoot>