C#中的阿拉伯语和英语 [英] Arabic and english in C#
本文介绍了C#中的阿拉伯语和英语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Windows应用程序.它只有一种形式.它必须同时使用阿拉伯语和英语.我试图翻译它,它也可以工作.但是问题是groupbox的内容没有翻译.我想包含一个应该转换为阿拉伯语的分组框.
我有一个组合框选择阿拉伯语和英语.
代码:
I have a windows application.In that there is one form .It needs to be in both arabic and english. I tried to translate it, Its working also.But the problem is that the groupbox contents is not translating. i want to include one groupbox that should convert in arabic.
I have one combobox selecting arabic and english.
Code :
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "Arabic")
{
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(Application.CurrentCulture);
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("ar"));
changelanguage("ar");
}
else
{
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("en-US"));
changelanguage("en-US");
}
}
private void changelanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resource = new ComponentResourceManager(typeof(frmNewTempl));
resource.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
预先表示感谢..
THanks in advance..
推荐答案
尝试递归控件遍历.
这可能会解决您的问题,因为它们在控件层次结构中的深度都不相同.
我是从这里为您找到的:
http://stackoverflow.com/questions/253937/recursive-control-search-with-linq [^ ]
Try a recursive control traverse.
It may solve your problem because all of them are not in the same depth in controls hierarchy.
I found this for you from here :
http://stackoverflow.com/questions/253937/recursive-control-search-with-linq[^]
public static IEnumerable<Control> GetAllControls(this Control parent)
{
foreach (Control control in parent.Controls)
{
yield return control;
foreach(Control descendant in control.GetAllControls())
{
yield return descendant;
}
}
}
还有其他几种递归遍历控件的方法.
使用它将资源应用于控件.
希望对您有所帮助.
There are several other ways to traverse controls recursively.
use it to apply resources to your controls.
Hope it helps.
这篇关于C#中的阿拉伯语和英语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文