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
Peter KiersOperatorAsked:
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.

Dirk HaestProject managerCommented:
Peter KiersOperatorAuthor 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
Dirk HaestProject managerCommented:
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.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Peter KiersOperatorAuthor Commented:
Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";

I got an error:

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

P.
Peter KiersOperatorAuthor 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'      
Dirk HaestProject managerCommented:
Did you add this using ?

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

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

            To

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

Thanks,
NetSwap.
Peter KiersOperatorAuthor Commented:
YIP
Peter KiersOperatorAuthor 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?)
SwapnilSoftware ArchitectCommented:
As error says add reference to System.Threading if it doesn't exist in your project.
Peter KiersOperatorAuthor 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?)
Dirk HaestProject managerCommented:
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

Peter KiersOperatorAuthor Commented:
I have this:

using System.Threading; //add


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

But then I get: instance is read-only
Dirk HaestProject managerCommented:
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

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
Peter KiersOperatorAuthor Commented:
Ahhh, it works thank you both Dhaest and NetSwap.
Points will be devided.

Greetings, Peter Kiers
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.