c# - Visual Studio 2010 - changing Language property -


is possible change language property of main form via code? if so, how?

details: in config file have set lang="en". want use localization setting change main form dependent on variable. have set localizable property true.

for example:

if (config.lang == "fr") {     //change **language** property "french" } else {     //remain (default) } 

the issue don't see language property anywhere in coding window no matter i'm wondering if it's possible this.

because of way resources managed in .net ui programs, easiest way set thread locale appropriately right @ start of program before create forms.

firstly determine culture want config file:

cultureinfo culture = ... whatever 

then set main thread's currentuiculture , currentculture locale:

system.threading.thread.currentthread.currentuiculture = culture; system.threading.thread.currentthread.currentculture   = culture; 

this code go program.cs @ start of main().

note if start other threads display ui (or output localised data), need same thing @ start of threads.

also note major limitation of approach cannot change locale while program running , have ui update reflect it. have set locale @ beginning of program.

there other solutions avoid limitation, waaay more complicated.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -