Problem with "Display leading zeros" Windows regional setting formating numeric values

  • Thread starter Thread starter Andrey Matveyev
  • Start date Start date
A

Andrey Matveyev

Hello everybody,
I found several problems formatting numeric values.
The first problem is that standard numeric format strings "N" or "n" doesn't
use "Display leading zeros" Windows regional settings (at the "Numbers"
tab), it always uses leading zero regardless Windows settings. I was
thinking to create and to use custom format string that takes into account
this setting, but CultureInfo.NumberFormat property seems doesn't have a
property that would expose this setting. Looks like that only one option
that I have is to use Windows API in order to get this setting and to create
correct format string.
Any ideas?

Thank you,
Andrey Matveyev

BTW.
Another small problem that I've found is that if .NET Windows application is
running and user makes changes in the regional settings and saves them the
application doesn't reflect these changes until users restarts it. I know
that Windows sends a special broadcast message that settings have been
changed. For example Delphi VCL (Visual Component Library) can do it at
runtime.
 
Andrey Matveyev said:
Hello everybody,
I found several problems formatting numeric values.
The first problem is that standard numeric format strings "N" or "n" doesn't
use "Display leading zeros" Windows regional settings (at the "Numbers"
tab), it always uses leading zero regardless Windows settings. I was
thinking to create and to use custom format string that takes into account
this setting, but CultureInfo.NumberFormat property seems doesn't have a
property that would expose this setting. Looks like that only one option
that I have is to use Windows API in order to get this setting and to create
correct format string.
Any ideas?

Thank you,
Andrey Matveyev

BTW.
Another small problem that I've found is that if .NET Windows application is
running and user makes changes in the regional settings and saves them the
application doesn't reflect these changes until users restarts it. I know
that Windows sends a special broadcast message that settings have been
changed. For example Delphi VCL (Visual Component Library) can do it at
runtime.

For your "broadcast notification" see the SystemEvents class.


--
Regards,

Jim Allison
(e-mail address removed)
(de-mung by removing '.1')
 
Back
Top