惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
L
LangChain Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
GbyAI
GbyAI
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
V
V2EX
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V2EX - 技术
V2EX - 技术
The Register - Security
The Register - Security
PCI Perspectives
PCI Perspectives
博客园 - 叶小钗
S
Secure Thoughts
Project Zero
Project Zero
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
U
Unit 42
T
Tor Project blog
美团技术团队
大猫的无限游戏
大猫的无限游戏
C
Cisco Blogs
S
Securelist
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
Microsoft Azure Blog
Microsoft Azure Blog
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Forbes - Security
Forbes - Security
IT之家
IT之家
A
Arctic Wolf
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
腾讯CDC
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
I
Intezer
N
News | PayPal Newsroom
Y
Y Combinator Blog
博客园_首页

博客园 - 云梦鸿

Linux使用笔记 QT 练习笔记 QT 读写配置文件(*.INI) ubuntu 配置网口静态IP C++ 读写文件 C#编写Windows服务 C#代码计算农历(日期、节气、节日) 中标麒麟,使用笔记 关于无密码访问 Windows7/10 的远程桌面/共享 颜色转换:HSB颜色 与 RGB颜色 QT 信号(槽)绑定的使用_connect QT 给控件(Label)设置显示图片 QT 打包Windows应用程序(*.exe) C#程序执行Python脚本 C#监控U盘插拔 C# AnimateWindow 设置窗体动画 C# GetWindowRect 获取窗体在屏幕中的位置信息 C# 创建音频WAVE文件头信息(*.wav) VS2019错误:CS8370 的处理方法
Winform界面显示的“语言”切换
云梦鸿 · 2026-03-12 · via 博客园 - 云梦鸿

1.按正常方式创建目标窗口,并完成界面布局设计。

image

 2.将界面显示内容,按默认“语言”设计。

image

3.保存默认的“语言”资源文件。

  • 选择目标窗口,打开窗口的”属性“页;
  • 找到“Language"和“Localizable"属性,设置”Localizable"为“True”。

image 

  •  此时,可以找到目标窗口对应的默认资源文件,双击查看。

image 

image

4. 设计第二种“语言”界面

  • 找到目标窗口,属性页中的“Language”,选择要使用的第二种语言(如“英语”);
  • 然后重新设计目标窗口中的显示内容:可修改显示内容、布局,不可增/减控件

image  image 

  • 保存后,可看到新的资源文件:xxxx.en.resx

image

image

 5.固定选择“语言”运行界面

  • 默认直接运行时,窗口显示风格为默认“语言”显示;
  • 若要切换为另一种“语言”显示,则可在窗口运行前,先执行如下代码;
   // 在软件启动时,设置显示语言
   string lang = "en";  // 英文:en   中文:zh-CN 
   System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);

image    image

6.动态切换“语言”显示

  • 为界面控件添加如下事件响应:
        // using System.ComponentModel
        // using System.Globalization;
        // using System.Threading;

        // 当前语言 
        ComponentResourceManager languageMgr = new ComponentResourceManager(typeof(LangueSelectForm));

        // 刷新界面控件
        private void RefreshAllControls(Control parentControl)
        {
            foreach (Control control in parentControl.Controls)
            {
                languageMgr.ApplyResources(control, control.Name);
                if (control.Controls.Count > 0)
                {
                    RefreshAllControls(control);
                }
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                string lang = "en"; // 切换为 “英语”
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                this.RefreshAllControls(this);
            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
            {
                string lang = "zh-CN"; // 切换为 “中文”(默认)
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                this.RefreshAllControls(this);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; // 切换为 默认
            this.RefreshAllControls(this);
        }

image    image

7.全局“语言”文本使用

  • 在“项目”-Properties,找到 ”Resources.resx“文件(默认资源文件),双击打开查看;
  • 添加要全局使用的字符串文件;

image

  •  添加另一个的新”语言“资源文件:右键→添加→类,找到”资源文件;
  • 命令为:Resources.en.resx (适用于“英语”语言)
  • 编辑这个资源文件,按新的“语言”给需要切换显示的文本输入新语言的“值”

image       image

  •  在适当的地方,将所选语言的字符串值,赋值给对应的界面显示。

image

image   image