I am using CB XE4-Pro. With the latest TMS component Pack. I am using 32bit VCL platform.
In Europe they use the comma (,) as the decimal separator for numbers. I am forcing my application to always display and get, numbers in U.S. format which uses a period (.) for the decimal separator. Are there any settings for the three TMS components below which will force them to always display and edit number in the U.S. format?
TAdvSpinEdit
TMaskEditEx
TAdvMaskEdit
Can I assign a local version of the TFormatSettings to these components when they are used?
TFormatSettings fmt = TFormatSettings::Create(); // get defaults
fmt.DecimalSeparator = _D('.');
fmt.ThousandSeparator = _D('\0');
Thanks
Patrick Mikula
These components should pickup & use the local setting of FormatSettings, so if you do this at application level, it should be automatically picked up to be consistent with these components.
The TFormatSettings is a local copy of the global settings. There is no application level version of the TFormatSettings. The application uses the global version or the local version if you provide one.
I need the Edits to always display a period(.) for the DecimalSeparator so I need one of the two setting below. I don't think there is any way to do this in the current Edits so I will make a feature request for this.
(1)
AdvSpinEdit->DecimalSeparator = _D('.');
(2)
TFormatSettings fmt = TFormatSettings::Create();
fmt.DecimalSeparator = _D('.');
fmt.ThousandSeparator = _D('\0');
AdvSpinEdit->FormatSettings = fmt;
I do not understand your remark. If you have a need to force application-wide to have a dot (.) as decimal separator, you'd need to set FormatSettings.DecimalSeparator = '.' and our controls will use this setting.
The decimal separator is an operating system wide setting. It can only be changed for the whole computer, which is not recommenced. I need to make the TAdvSpinEdit and MaskEdits display a (.) decimal separator without changing the operating system wide setting. This is what I don't know how to do?
There is no way to change the decimal separator just for one application. I am making a local copy of the TFormatSettings which includes the decimal separator and using the local copy. This is how functions like FloatToStr() are recommenced to be used.
TFormatSettings fmt = TFormatSettings::Create();
fmt.DecimalSeparator = _D('.');
UnicodeString MyStr = FloatToStr( MyFloat, fmt);
Changing FormatSettings.DecimalSeparator does NOT affect the operating system setting, only the application level setting.