在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;
using System.Threading;
using System.Globalization;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("zh-Hans");
ApplyResource();
}
private void button2_Click(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
ApplyResource();
}
public void ApplyResource()
{
System.ComponentModel.ComponentResourceManager res = new ComponentResourceManager(typeof(Form1));
this.textBox1.Text = res.GetString("textBox1.Text");
this.pictureBox1.Image = res.GetObject("1") as Image;
}
把Form1.zh-Hans.resx和Form1.en-US.resx中的图片名称改成一样。
初始化是使用到的图片,放在perproties\resources.resx中。
参考链接:
http://www.cnblogs.com/flyinghigher/archive/2012/03/20/2408874.html