Is it possible to change country settings of windows with code?

Hi,

I don't know exactly how this icon is called in the English version of Windows (example1).
But I like to change one specific setting of the country settings (example2a).

How can I do that?

Peter

Example1.jpg
Example2a.jpg
LVL 1
peterkiersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
0
peterkiersAuthor Commented:
I am not exaclty sure what to do with this link.

What I would like in the the loadevent of my form that it changes the setting Decimaalteken (means Decimal Sign)
taht I have marked it with an arrow instead of a comma (,) I want a (.) period.

PK
0
DhaestCommented:
You can change the decimal separator by changing the culture used to display the number. Beware however that this will change everything else about the number (eg. grouping separator, grouping sizes, number of decimal places). From your question, it looks like you are defaulting to a culture that uses a comma as a decimal separator.

To change just the decimal separator without changing the culture, you can modify the NumberDecimalSeparator property of the current culture's NumberFormatInfo.
Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";

 This will modify the current culture of the thread. All output will now be altered, meaning that you can just use value.ToString() to output the format you want, without worrying about changing the culture each time you output a number.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

peterkiersAuthor Commented:
Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";

I got an error:

The name 'Thread' does not exist in the current context

P.
0
peterkiersAuthor Commented:
       private void Chart1_Load(object sender, EventArgs e)
        {
            System.Threading.Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";   <=================
            chartControl1.DataSource = CreateChartData(50);
            chartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
            chartControl1.Series[0].ArgumentDataMember = "Argument";
            chartControl1.Series[0].ValueScaleType = ScaleType.Numerical;
            chartControl1.Series[0].ValueDataMembers.AddRange(new string[] { "Value" });
        }

ERROR:
An object reference is required for the non-static field, method, or property 'System.Threading.Thread.CurrentCulture.get'      
0
DhaestCommented:
Did you add this using ?

using System.Threading;
0
SwapnilSoftware ArchitectCommented:
Hi Peterkiers,
       
          Change

          System.Threading.Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";  

            To

         System.Threading.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";  

Thanks,
NetSwap.
0
peterkiersAuthor Commented:
YIP
0
peterkiersAuthor Commented:
       private void Chart1_Load(object sender, EventArgs e)
        {
            System.Threading.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";  
            chartControl1.DataSource = CreateChartData(50);
            chartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
            chartControl1.Series[0].ArgumentDataMember = "Argument";
            chartControl1.Series[0].ValueScaleType = ScaleType.Numerical;
            chartControl1.Series[0].ValueDataMembers.AddRange(new string[] { "Value" });
        }

ERROR:
The type or namespace name 'CurrentThread' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)
0
SwapnilSoftware ArchitectCommented:
As error says add reference to System.Threading if it doesn't exist in your project.
0
peterkiersAuthor Commented:
using System.Threading; //add


        private void Chart1_Load(object sender, EventArgs e)
        {
            System.Threading.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";  <======
            chartControl1.DataSource = CreateChartData(50);
            chartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
            chartControl1.Series[0].ArgumentDataMember = "Argument";
            chartControl1.Series[0].ValueScaleType = ScaleType.Numerical;
            chartControl1.Series[0].ValueDataMembers.AddRange(new string[] { "Value" });
        }

ERROR:
The type or namespace name 'CurrentThread' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)
0
DhaestCommented:
Try

System.Threading.Thread.CurrentThread
using System.Threading; //add


        private void Chart1_Load(object sender, EventArgs e)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";  <======
            chartControl1.DataSource = CreateChartData(50);
            chartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
            chartControl1.Series[0].ArgumentDataMember = "Argument";
            chartControl1.Series[0].ValueScaleType = ScaleType.Numerical;
            chartControl1.Series[0].ValueDataMembers.AddRange(new string[] { "Value" });
        }

Open in new window

0
peterkiersAuthor Commented:
I have this:

using System.Threading; //add


Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";

But then I get: instance is read-only
0
DhaestCommented:
System. Globalization. CultureInfo myCI = (System. Globalization. CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone ();

myCI.NumberFormat. NumberDecimalSeparator = ".";

System.Threading.Thread.CurrentThread.CurrentCulture = myCI;

using System.Threading; //add


        private void Chart1_Load(object sender, EventArgs e)
        {
            System. Globalization. CultureInfo myCI = (System. Globalization. CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone ();
myCI.NumberFormat. NumberDecimalSeparator = ".";

System.Threading.Thread.CurrentThread.CurrentCulture = myCI;

            chartControl1.DataSource = CreateChartData(50);
            chartControl1.Series[0].ArgumentScaleType = ScaleType.Qualitative;
            chartControl1.Series[0].ArgumentDataMember = "Argument";
            chartControl1.Series[0].ValueScaleType = ScaleType.Numerical;
            chartControl1.Series[0].ValueDataMembers.AddRange(new string[] { "Value" });
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peterkiersAuthor Commented:
Ahhh, it works thank you both Dhaest and NetSwap.
Points will be devided.

Greetings, Peter Kiers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.