由网友(厌烦.)分享简介:我在C#创建Windows窗体程序。我有一些问题定位。我有2种语言资源文件(其中一个是英语,另一个是法国人)。我想单击每个语言按钮,切换语言在运行时。I have created Windows Form Program in C#. I have some problems with localization. I...
我在C#创建Windows窗体程序。我有一些问题定位。我有2种语言资源文件(其中一个是英语,另一个是法国人)。我想单击每个语言按钮,切换语言在运行时。
I have created Windows Form Program in C#. I have some problems with localization. I have resource files in 2 languages(one is for english and another is for french). I want to click each language button and change language at runtime.
但是,当我点击按钮,这是行不通的。我用这code。
But when i am clicking on button, it doesn't work. i am using this code.
private void btnfrench_Click(object sender, EventArgs e)
{
getlanguage("fr-FR");
}
private void getlanguage(string lan)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager cmp =
new ComponentResourceManager(typeof(BanksForm));
cmp.ApplyResources(c, c.Name, new CultureInfo(lan));
}
}
将任何请在这方面的帮助......
would any pls help on this......
非常感谢......
Many Thanks....
推荐答案
这工作:
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-BE");
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(this, "$this");
applyResources(resources, this.Controls);
}
private void applyResources(ComponentResourceManager resources, Control.ControlCollection ctls)
{
foreach (Control ctl in ctls)
{
resources.ApplyResources(ctl, ctl.Name);
applyResources(resources, ctl.Controls);
}
}
要小心,以避免增加口哨这样,没有人会永远使用。
Be careful to avoid adding whistles like this that nobody will ever use.
相关推荐
最新文章