在c#中的windows应用程序中的用户选择时,在运行时更改UI语言。 [英] change the UI language at run time at user selection in windows application in c#.
本文介绍了在c#中的windows应用程序中的用户选择时,在运行时更改UI语言。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Windows应用程序中的用户选择时在运行时更改UI语言。我怎么能这样做?
解决方案
根据用户选择设置CurrentCulture和CurrentUICulture
// 将using语句放在代码模块的开头
使用 System.Threading;
使用 System.Globalization;
// 将以下代码放在InitializeComponent()之前
// 将文化设置为法语(法国)
Thread.CurrentThread.CurrentCulture = new CultureInfo( fr-FR);
// 将UI文化设置为法语(法国)
Thread.CurrentThread .CurrentUICulture = new CultureInfo( fr-FR);
ref:http://msdn.microsoft.com/en-us/library/b28bx3bh(v=vs.110).aspx [ ^ ]
如果您需要更改按钮点击或菜单项选择等文化..请查看以下文章
动态更改应用程序用户界面文化 [ ^ ]
这个SO答案如何更改运行时WinForms应用程序的文化 [ ^ ]
I need to change the UI language at run time at user selection in windows application. How can I do that?
解决方案
set CurrentCulture and CurrentUICulture based on user selection
// Put the using statements at the beginning of the code module using System.Threading; using System.Globalization; // Put the following code before InitializeComponent() // Sets the culture to French (France) Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); // Sets the UI culture to French (France) Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
ref :http://msdn.microsoft.com/en-us/library/b28bx3bh(v=vs.110).aspx[^]
If you need to change the culture on button click or menu item selection etc.. check below article
Changing Your Application User Interface Culture On The Fly[^]
And this SO answer How do I change the culture of a WinForms application at runtime[^]
这篇关于在c#中的windows应用程序中的用户选择时,在运行时更改UI语言。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文