KansaiRobot
KansaiRobot

Reputation: 10032

changing culture for a winform application

As explained here I have built a sample console application in which I change the culture in the Main function. It works well.

Now, building another sample winform application, I wonder where would be the best place to put this

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture ("en-US");
Thread.CurrentThread.CurrentUICulture=new CultureInfo("en-US");

If I put this in the constructor of a Form1, will this apply to all operations in this class?

What if this Form1 opens another form Form2 and an exception occurs there?

What if Form1 uses another class Class1?

I am willing to experiment in this, but if someone has an answer based on previous knowledge, I appreciate to hear it.

Upvotes: -1

Views: 683

Answers (1)

TheGeneral
TheGeneral

Reputation: 81583

For a winforms application put things that deal with the context of the entire application in program.cs and be done with it.

  • If I put this in the constructor of a Form1, will this apply to all operations in this class?

  • What if this Form1 opens another form Form2 and an exception occurs there?

  • What if Form1 uses another class Class1?

All your other concerns are irrelevant, and are sereverly overthinking the problem.

Note : The best way to learn programming windows or any other language is to read as much as you can. Microsoft have everything documented always go straight to the source.

Some additional reading for you

Thread.CurrentUICulture Property

Thread.CurrentCulture Property

Initialization code in a WinForms App - Program.cs or MainForm?

Upvotes: 2

Related Questions