Changing System Culture

4

Developing a system for a Bolivian company, on a windows with culture pt-BR , some objects like datetimepicker have their internal components according to the language in which the system was installed. Home And in my case, when this system was installed in Bolivia, no windows will have as culture es-BO , so it would need a way through code that the exchange of culture is made so that these objects have their components with texts in Spanish and not with the culture and that the system was installed.

According to the documentation this culture exchange must occur before the components are initialized (% w / o%) with the following lines of code:

Thread.CurrentThread.CurrentCulture = new CultureInfo("es-BO");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-BO");

But even using this solution, my result continued being the texts of the object all in Portuguese. The exchange comes to occur but the system "automatically" returns the culture to the initial? or am I making this trade the wrong way?

    
asked by anonymous 23.09.2014 / 16:10

2 answers

3

The technique of changing Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture does not work for DateTimePicker control and MonthCalendar control, as explained by Microsoft itself:

The DateTimePicker and MonthCalendar control do not reflect the CurrentUICulture property

According to the article, these controls take into account only the system settings in Control Panel. So to change them, you need to effectively change the entire system settings.

Proof of this is that if you change Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture , to "en-US" , for example, the NumericUpDown control will effectively respect your choice by changing the thousands and decimal separator. agreement.

So, it can be said that the technique works for "almost" everything ... except for the DateTimePicker and MonthCalendar controls (and eventually others that are tied to system settings).     

24.09.2014 / 15:06
0

My application had the same problem. The problem was solved when I did so:

Thread.CurrentThread.CurrentCulture = new CultureInfo("es-BO", true); Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-BO", true);

    
23.09.2014 / 22:30