zoukankan      html  css  js  c++  java
  • winfrom 多语言切换

    1、首先将窗体的“Localizable”属性置为“True”,然后将“Language”属性置为自己想要的语言,点击重新生成项目

    例如:置为“中文”,以及“英文”。当每次置为不同的语言并重新生成项目后,将“Languate”属性再次置为默认,并重新生成项目

    这一系列操作后,该窗体会为每一个不同的语言生成一个窗体资源文件"窗体名称.语种.resx"

    英文:en-US  中文:zh-CN

    将这两个资源文件中控件的Text属性设置成相应语种的名称,例如英文的

    然后在切换语言的时候,执行以下方法为控件设置

            /// <summary>
            /// 设置控件的 Text 属性
            /// </summary>
            private void SetControlText()
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
                ComponentResourceManager resources = new ComponentResourceManager(typeof(MainForm));
                resources.ApplyResources(this, "$this");
                SetApply(this, resources);
            }
    
            private void SetApply(Control cs, ComponentResourceManager r)
            {
                foreach (Control c in cs.Controls)
                {
                    r.ApplyResources(c, c.Name);
                    SetApply(c, r);
                }
            }

  • 相关阅读:
    easyui-datetimebox设置默认时分秒00:00:00
    分页工具类的封装
    关于查询排序DTO的封装
    android签名生成和发布
    android httpclient 设置超时
    Eclipse 模拟http 请求插件Rest Client
    volley 发送post请求
    mac book 华为C8815不能debug
    android一些小技巧
    PS相关技术
  • 原文地址:https://www.cnblogs.com/rogation/p/3522142.html
Copyright © 2011-2022 走看看