Peter Kiers
asked on
Loading values from the Settings.Settings-file incorrect.
Dear Experts,
I have 4 variables declared in the Settings.Settings-file:
Name = MinVal, Type = string, Value = 3.9
Name = MinRng, Type = string, Value = 4.4
Name = MaxRng, Type = string, Value = 6.7
Name = MaxVal, Type = string, Value = 8.3
And this I have in the loadevent of my dialog-form called Settings:
But in my 4 spinedit-components from DevExpress I get these
values:
39,0 - 44,0 - 67,0 - 83,0
instead of:
3,9 - 4,4 - 6,7 - 8,3
How can I solve this?
Who knows the answer and is willing to help me?
Greetings,
Peter Kiers
I have 4 variables declared in the Settings.Settings-file:
Name = MinVal, Type = string, Value = 3.9
Name = MinRng, Type = string, Value = 4.4
Name = MaxRng, Type = string, Value = 6.7
Name = MaxVal, Type = string, Value = 8.3
And this I have in the loadevent of my dialog-form called Settings:
private void Settings_Load(object sender, EventArgs e)
{
this.spdMinVal.Text = Properties.Settings.Default.MinVal;
this.spdMinRng.Text = Properties.Settings.Default.MinRng;
this.spdMaxRng.Text = Properties.Settings.Default.MaxRng;
this.spdMaxVal.Text = Properties.Settings.Default.MaxVal;
}
But in my 4 spinedit-components from DevExpress I get these
values:
39,0 - 44,0 - 67,0 - 83,0
instead of:
3,9 - 4,4 - 6,7 - 8,3
How can I solve this?
Who knows the answer and is willing to help me?
Greetings,
Peter Kiers
Does that control have a Value() property instead of a Text() one?
ASKER
Hi,
When I change the default values to "3,9", "4,4" etc.. computers in the US doesn't recognize this. Because you use a period instead of a comma.
so I get: "39.0", "44.0" etc.. And ofcaurse visa versa. When I change the default values to "3.9", "4.4" etc.. I get "39,0", "44,0". Because we use
a comma instead of a period. So what I want to try is to set the default values with a period. But when the form is loaded the code has to check
the currentculure and convert it. I have this line of code from my previous question:
private System.Globalization.Cultu reInfo ci = System.Threading.Thread.Cu rrentThrea d.CurrentC ulture;
Is it posible in this load-event the code read the default-values and the checks the current culture and convert the value
and display it then in the spinedit-components.
private void Settings_Load(object sender, EventArgs e)
{
this.spdMinVal.EditValue = Properties.Settings.Defaul t.MinVal;
this.spdMinRng.EditValue = Properties.Settings.Defaul t.MinRng;
this.spdMaxRng.EditValue = Properties.Settings.Defaul t.MaxRng;
this.spdMaxVal.EditValue = Properties.Settings.Defaul t.MaxVal;
}
Greetings,
Peter Kiers
When I change the default values to "3,9", "4,4" etc.. computers in the US doesn't recognize this. Because you use a period instead of a comma.
so I get: "39.0", "44.0" etc.. And ofcaurse visa versa. When I change the default values to "3.9", "4.4" etc.. I get "39,0", "44,0". Because we use
a comma instead of a period. So what I want to try is to set the default values with a period. But when the form is loaded the code has to check
the currentculure and convert it. I have this line of code from my previous question:
private System.Globalization.Cultu
Is it posible in this load-event the code read the default-values and the checks the current culture and convert the value
and display it then in the spinedit-components.
private void Settings_Load(object sender, EventArgs e)
{
this.spdMinVal.EditValue = Properties.Settings.Defaul
this.spdMinRng.EditValue = Properties.Settings.Defaul
this.spdMaxRng.EditValue = Properties.Settings.Defaul
this.spdMaxVal.EditValue = Properties.Settings.Defaul
}
Greetings,
Peter Kiers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops...Line #23 should be:
this.spdMaxRng.EditValue = MaxRng.ToString(); // <-- uses the current culture
this.spdMaxRng.EditValue = MaxRng.ToString(); // <-- uses the current culture
ASKER
Thanks Idle_Mind.
Peter
Peter
Why do you define your settings as strings when they are numbers? You will end up with the same kind of problems that you would get by defining a numeric field as text in a database.
If you define your settings as numerical values and apply ToString to them, they will automatically convert to the proper format for the environment in which they run.
Name = MinVal, Type = string, Value = 3.9
this.spdMinVal.Text = Properties.Settings.Defaul t.MinVal.T oString()
If you define your settings as numerical values and apply ToString to them, they will automatically convert to the proper format for the environment in which they run.
Name = MinVal, Type = string, Value = 3.9
this.spdMinVal.Text = Properties.Settings.Defaul