当前位置: 首页 > article >正文

【C#】C# resx方式实现多语言切换(静态切换)

1. 效果

  • 中文界面
    在这里插入图片描述

  • 英文界面
    在这里插入图片描述

2. 步骤

1. 添加resx文件

在这里插入图片描述

2. Form1.en-GB.resx内容

在这里插入图片描述

3. Form1.zh-CN.resx内容

在这里插入图片描述

4. Form1.cs修改(重点)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            //英文
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB");

            //中文
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");

            InitializeComponent();
        }
    }
}

3. 参考

  • C#的窗体应用程序的多语言实现
  • C#的Winform多语言实现(resx文件)

http://www.kler.cn/a/416194.html

相关文章:

  • RAG架构类型
  • 物联网客户端在线服务中心(客服功能/私聊/群聊/下发指令等功能)
  • 【视频】OpenCV:读写视频文件VideoCapture和VideoWriter
  • HarmonyOS4+NEXT星河版入门与项目实战(23)------实现手机游戏摇杆功能
  • Flink四大基石之Time (时间语义) 的使用详解
  • Android使用UVCCamera打开USBCamera-预览
  • 安卓-碎片的使用入门
  • 浏览器的数据六种存储方法比较 :LocalStorage vs. IndexedDB vs. Cookies vs. OPFS vs. WASM-SQLite
  • 设计一个基于 LSTM 神经网络的文本分类器
  • 如何利用Java爬虫获取1688关键词接口的深度解析
  • String的设计,用到了哪些设计模式?
  • Window 安装 Nginx
  • JavaScript零基础入门速通(完整)
  • 虚拟机CentOS系统通过Docker部署RSSHub并映射到主机
  • ISO 26262与敏捷SPICE:汽车软件开发的双重指南
  • 网关: 用途和产品对比
  • 【Java基础入门篇】三、面向对象和JVM底层分析(1)
  • 【设计模式】【结构型模式(Structural Patterns)】之适配器模式(Adapter Pattern)
  • CentOS 上安装各种应用的命令行总结
  • Tomcat(39)如何在Tomcat中配置SSL会话缓存?