用窗体的language的属性可以达到这个效果,打开一个窗口点击进去可以发现,比如说选择中文,将会产生一个.zh-CN.resX文件。你在窗口修改的汉字将会存入其中。当你的程序debug之后将会产生一个文件夹、其中有一个resource.dll文件就是这个东东。你可以添加一个语言的菜单,把你的语言列在下面,然后编辑菜单的click事件来设定线程的文化信息。不知道这么说你明白了没有。下面是一个例子。  using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Resources;
using System.IO;namespace TestLanguage
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Globalization.CultureInfo currentCulture = null; private System.Globalization.CultureInfo zh_CN = System.Globalization.CultureInfo.CreateSpecificCulture("zh-CN");
private System.Globalization.CultureInfo en_US = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); /// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
currentCulture = en_US;
System.Threading.Thread.CurrentThread.CurrentUICulture = currentCulture;
InitializeComponent(); string path = Directory.GetCurrentDirectory();
if (File.Exists(path+"\\zh-CHS\\TestLanguage.resources.dll"))
{
menuItem3.Enabled = true;
menuItem3.Visible = true;
}
else
{
menuItem3.Enabled = false;
menuItem3.Visible = false;
}
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
// 
// mainMenu1
// 
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  this.menuItem1});
this.mainMenu1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("mainMenu1.RightToLeft")));
// 
// menuItem1
// 
this.menuItem1.Enabled = ((bool)(resources.GetObject("menuItem1.Enabled")));
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  this.menuItem2,
  this.menuItem3});
this.menuItem1.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("menuItem1.Shortcut")));
this.menuItem1.ShowShortcut = ((bool)(resources.GetObject("menuItem1.ShowShortcut")));
this.menuItem1.Text = resources.GetString("menuItem1.Text");
this.menuItem1.Visible = ((bool)(resources.GetObject("menuItem1.Visible")));
// 
// menuItem2
// 
this.menuItem2.Enabled = ((bool)(resources.GetObject("menuItem2.Enabled")));
this.menuItem2.Index = 0;
this.menuItem2.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("menuItem2.Shortcut")));
this.menuItem2.ShowShortcut = ((bool)(resources.GetObject("menuItem2.ShowShortcut")));
this.menuItem2.Text = resources.GetString("menuItem2.Text");
this.menuItem2.Visible = ((bool)(resources.GetObject("menuItem2.Visible")));
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
// 
// menuItem3
// 
this.menuItem3.Enabled = ((bool)(resources.GetObject("menuItem3.Enabled")));
this.menuItem3.Index = 1;
this.menuItem3.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("menuItem3.Shortcut")));
this.menuItem3.ShowShortcut = ((bool)(resources.GetObject("menuItem3.ShowShortcut")));
this.menuItem3.Text = resources.GetString("menuItem3.Text");
this.menuItem3.Visible = ((bool)(resources.GetObject("menuItem3.Visible")));
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
// 
// Form1
// 
this.AccessibleDescription = ((string)(resources.GetObject("$this.AccessibleDescription")));
this.AccessibleName = ((string)(resources.GetObject("$this.AccessibleName")));
this.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("$this.Anchor")));
this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
this.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("$this.Dock")));
this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
this.Menu = this.mainMenu1;
this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
this.Name = "Form1";
this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
this.Text = resources.GetString("$this.Text");
this.Visible = ((bool)(resources.GetObject("$this.Visible"))); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void menuItem2_Click(object sender, System.EventArgs e)
{
string a = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
if(a !="en-US")
{
currentCulture = en_US;
System.Threading.Thread.CurrentThread.CurrentUICulture = currentCulture;
menuItem2.Checked = true;
menuItem3.Checked = false;
resettext();
}
} private void menuItem3_Click(object sender, System.EventArgs e)
{
string a = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
if(a != "zh-CN")
{
currentCulture = zh_CN;
System.Threading.Thread.CurrentThread.CurrentUICulture = currentCulture;
menuItem2.Checked = false;
menuItem3.Checked = true;
resettext();
}
} private void resettext()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.Text = resources.GetString("$this.Text");
} }
}

解决方案 »

  1.   

    http://www.microsoft.com/china/community/TechZone/TechArticle/TechDoc/how_resourcefile.asp
      

  2.   

    需要详细的解,不要告诉我用什么实现,用什么实现我已经知道了,但是始终找不到如何实现的办法,最好象一层的住客那样,告诉我你的实现方法,只要例子就够了,越简单越能说明问题就最好了,谢谢。 也可以直接把例程发到我[email protected]的信箱里面,发给我源码一定给分
      

  3.   

    收到了没有,楼主?
      我那个东西就是为了检测这个的,如果你把debug目录下面的zh-CHS文件夹移除的话,在语言选项里面的中文就不见了。