C#语言切换例程

来源:互联网 发布:男朋友体力好体验知乎 编辑:程序博客网 时间:2024/05/02 06:44

1. 新建窗体
2. 属性设置

3. 设置中文


注:设置完成后会生成一个配置文件

4. 事件设置,双击如图语言进行事件编辑


5. 代码实现









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;using System.Threading;namespace LanguageStitch{    public partial class Form1 : Form    {        public Form1()        {            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");            InitializeComponent();        }        private void englishToolStripMenuItem_Click(object sender, EventArgs e)        {            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");            this.Controls.Clear();            InitializeComponent();        }        private void chineseToolStripMenuItem_Click(object sender, EventArgs e)        {            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");            this.Controls.Clear();            InitializeComponent();        }    }}












0 0
原创粉丝点击