arrghh dot vs comma

G

Guest

Hi ,,

i live in Europe in Europe the decimal seperator is , not a .
why is it so that if i press on my numeric keypad the . a . appears ??

in my opinion it should be a , ( sounds odd but ... it should be so )

my problem :

i work currently in a companny where people do data entry with the numeric
keypad we are rewriting a cobol program ,,, in cobol you could just say
decimal seperator = dot or comma and it would work as expected . how can we
simulate the same thing in .net ??

windows settings are correct ( dutch settings ) , we work with a standard
qwerty international keyboards on all computers

so what i would like is that only the numeric keypad . will give a , as
this is the numeric seperator symbol the keyboards ,. ( the ones below <>
) should work as they do.

someone an idea ???

regards

Michel Posseth
 
T

tomb

M. Posseth said:
Hi ,,

i live in Europe in Europe the decimal seperator is , not a .
why is it so that if i press on my numeric keypad the . a . appears ??

in my opinion it should be a , ( sounds odd but ... it should be so )

my problem :

i work currently in a companny where people do data entry with the numeric
keypad we are rewriting a cobol program ,,, in cobol you could just say
decimal seperator = dot or comma and it would work as expected . how can we
simulate the same thing in .net ??

windows settings are correct ( dutch settings ) , we work with a standard
qwerty international keyboards on all computers

so what i would like is that only the numeric keypad . will give a , as
this is the numeric seperator symbol the keyboards ,. ( the ones below <>
) should work as they do.

someone an idea ???

regards

Michel Posseth
Is there some way of remapping that particular key?

T
 
F

Fred Hedges

I don't know if this will work; maybe overriding the keypress event? Will
it have side effects further on down the line?



Protected Overrides Sub OnKeyPress(ByVal e As
System.Windows.Forms.KeyPressEventArgs)

If e.KeyChar = "."c Then

Dim theNewEvent As New System.Windows.Forms.KeyPressEventArgs(","c)

MyBase.OnKeyPress(theNewEvent)

Else

MyBase.OnKeyPress(e)

End If

End Sub
 
G

Guest

Well ,,,

the calculator does it and excel does it

so there must be a way that we can do it to

i just found this

http://www.theproblemsolver.nl/dotnet_faq.htm

###############
Keyboard input of numeric values and commas as decimal separator
One of the questions I frequently get is how to get the same behavior as
Excel when entering numeric values. With the same behavior I mean that Excel
detects the current users setting for decimal separator and makes the point
on the numeric keyboard input the correct character. This is only done for
the numeric keypad, the point and comma on regular part of the keyboard
remain unchanged. Doing so is very easy but finding the right place is not
completely obvious as in most events the KeyEventArgs or Message parameters
cannot be changed or changing them has no effect. The proper place to do
this is the PreProcessMessage() function of a control. The code below does
just that, just subclass the a TextBox control and override the
PreProcessMessage() function and you are done.



Public Overrides Function PreProcessMessage( _
ByRef msg As System.Windows.Forms.Message) As Boolean
If msg.Msg = &H102 Then
If msg.WParam.Equals(New IntPtr(&H2E)) _
AndAlso msg.LParam.Equals(New IntPtr(&H530001)) Then
' Point in the numeric keypad pressed
If
Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ","
Then
' And the decimal separator is a ',' for the current settings
' Change the message to enter a comma instead of a poin
msg.WParam = New IntPtr(&H2C)
msg.LParam = am = New IntPtr(&H330001)
End If
End If
End If

' Do the default actions
Return MyBase.PreProcessMessage(msg)
End Function

###################

however this doesn`t work on a datagridview control

aaarghhh

:-(

why are things that should be easy sometimes so hard to acomplish :-|
 
H

Hugh Janus

This is by design and should not affect your program.

You can recreate this in other windows apps like calc.exe. If it type
"9.9", "9.9" appears on the window. Anway, you can customise it in the
regional settings applet from control panel.
 
G

Guest

i have thought about this to however then you are not able to use a . when
you might need it


if i have a grid with 2 fileds for instance and i need to enter in the
second filed m. posseth i would get m, posseth

so it should only work on the numeric keypad`s .

regards

Michel Posseth
 
G

Guest

no not true

when i open calc or excel the keys are mapped

so i see 3,60 when i actually press 3.60 on my numeric keypad ( this is
how it should work )

however in my program or in notepad when i press the numeric seperator i
recive a . and i need it to be a , ( because of the regional settings )

as you see above in this thread there are workarounds that work on textbox
controls etc etc however it doesn`t seem to work on the datagridview control


anyone an idea

regards

Michel posseth





regards

Michel Posseth
 
C

Cor Ligthert [MVP]

Michael,

Yes I know the problem in Holland, I once had a job where I was in tight
contact with IBM PC division.(which I assume had about 90% of the market
than).

I had the same problem as you and asked all the time at by instance Dutch
IBM Dealer meetings for a Dutch keyboard, meaning with that is the decimal
separator a comma instead of a dot and some additions to use the florin, and
some French characters signs under an alt key.

They were glad to present me at a certain moment the Dutch keyboard. I did
not understand how people could have made such a keyboard, but they told
that it was according the standard specification for a Dutch Typewriter from
somewhere before the World War II.

I am sorry; I myself have never used those and tried to avoid selling them.
But in that terrible thing is the decimal separator a comma. (I don't advice
you to use it, it is in my opinion ever worse than Azerty for us)

Cor
 
P

Patrice

On hwihc control have you tried Fred suggestion. IMO it shoulmd be done on a
control by control basis (for example you may want to use , instead of . for
a textbox that accept numeric values but would lioke still to use . if the
textbox is for entering text).
 
M

Michel Posseth [MCP]

Exact and that is the reasson why i only want it on the numeric keypad dot
( this is how the Calculator and Excel do this )

regards

Michel Posseth
 
M

Michel Posseth [MCP]

Well Cor there must be a programatic solution ,,, as Microsoft uses this in
there products ( look at the calculator and Excel ) there the numeric
seperator key ( . on numeric keypad ) is swapped with a , if you go to
notepad the . still displays a . so i guess they are intercepring the
key in the program in some way

i have found some code that claimed it could do this the same way ( see up
in the thread ) however this doesn`t work in a datagridview control

regards

Michel
 
H

Herfried K. Wagner [MVP]

M. Posseth said:
i live in Europe in Europe the decimal seperator is , not a .
why is it so that if i press on my numeric keypad the . a . appears ??

in my opinion it should be a , ( sounds odd but ... it should be so )

On my German ('de-AT') system pressing the "," key on the numpad a ","
appears. "," is the decimal separator in 'de-AT' and 'de-DE'.
 
C

Cor Ligthert [MVP]

Herfried,

On the Dutch keyboard as well in Holland, but there is probably no sole that
is using that.

Cor
 
M

Michel Posseth [MCP]

yes that is probably the hole problem that eveyone in the Netherlands is
using a international QWERTY keyboard
however in my opinion it is strange that MS programs tackle this problem by
remapping the keys during runtime and that there seems to be no standard
method to reproduce this behavior for us .

if i could remap it permanently through a registry setting this would work
for me ( only for the dot on the numeric keypad should a comma appear )

so if someone knows how to do this i would be verry happy :)

regards

Michel Posseth



Cor Ligthert said:
Herfried,

On the Dutch keyboard as well in Holland, but there is probably no sole
that is using that.

Cor
 
C

Cor Ligthert [MVP]

Michel,

I thought trying to to this problem for you today, I am not sure if I have
time for that because I go out in some minutes.

It would be based on the fact that you can cast a textbox in a datagrid and
use its events.

I would use the keyup event and watch if the value is a dot and replace that
than by a comma and a comma by a dot. (You have than to play with the
selected position and things like that, but I assume that you know that,
there are plenty of samples in this newsgroup about the numeric textbox and
in fact do you have to extend that).

I had the idea that I did something before.

Cor
 
G

Guest

Thank you Cor,

I am happy that you understand the problem :)


i have just found a workaround that unfortanitly is not exactly what i want

if i add this key to the registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,33,00,53,00,00,00,00,00

it works great , however waht if the user changes his settings to for
instance US settings ?? well the dot will then still produce a , so he needs
to remove the registry key

also a problem is that the user should log off and log on before the added
key takes effect

it would be much nicer if there is a way to simulate the behavior on program
start and remove it on program end

or as you mentioned if it is possible to trap the key events on certain
columns in the datagridview and change the numeric dot for a comma this
would be nice , overall trapping wouldn`t work as it must be possible to
enter in a text column in the datagrid M. Posseth and in the column besides
it 8,99

where the dot after M. is made with >. key and the 8,99 is made with
the del. key ofcourse it is no problem if del. key creates in the first
column a . and in the second wich holds numeric values creates a ,

regards

Michel Posseth
 
G

Guest

Sometimes the solution can be so simple ,,, you just have to see it


so for all you outta there with us keyboards in european country`s ( like it
is the standard in the Netherlands )

take a form set it`s keypreview property to true

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Decimal AndAlso
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator =
"," Then
e.SuppressKeyPress = True
My.Computer.Keyboard.SendKeys(","c)
End If

End Sub

now it works exactly as calc.exe and Excel thus numeric seperator on the
num pad ( . ) will now give a , if this is the system setting

regards

and thanks to all of you for thinking with me to solve this problem

regards

Michel Posseth




M. Posseth said:
Thank you Cor,

I am happy that you understand the problem :)


i have just found a workaround that unfortanitly is not exactly what i want

if i add this key to the registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,33,00,53,00,00,00,00,00

it works great , however waht if the user changes his settings to for
instance US settings ?? well the dot will then still produce a , so he needs
to remove the registry key

also a problem is that the user should log off and log on before the added
key takes effect

it would be much nicer if there is a way to simulate the behavior on program
start and remove it on program end

or as you mentioned if it is possible to trap the key events on certain
columns in the datagridview and change the numeric dot for a comma this
would be nice , overall trapping wouldn`t work as it must be possible to
enter in a text column in the datagrid M. Posseth and in the column besides
it 8,99

where the dot after M. is made with >. key and the 8,99 is made with
the del. key ofcourse it is no problem if del. key creates in the first
column a . and in the second wich holds numeric values creates a ,

regards

Michel Posseth







Cor Ligthert said:
Michel,

I thought trying to to this problem for you today, I am not sure if I have
time for that because I go out in some minutes.

It would be based on the fact that you can cast a textbox in a datagrid and
use its events.

I would use the keyup event and watch if the value is a dot and replace that
than by a comma and a comma by a dot. (You have than to play with the
selected position and things like that, but I assume that you know that,
there are plenty of samples in this newsgroup about the numeric textbox and
in fact do you have to extend that).

I had the idea that I did something before.

Cor
 
C

Cor Ligthert [MVP]

Michel,

If you use the key up event it is mostly even more simple.

Cor

M. Posseth said:
Sometimes the solution can be so simple ,,, you just have to see it


so for all you outta there with us keyboards in european country`s ( like
it
is the standard in the Netherlands )

take a form set it`s keypreview property to true

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Decimal AndAlso
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator =
"," Then
e.SuppressKeyPress = True
My.Computer.Keyboard.SendKeys(","c)
End If

End Sub

now it works exactly as calc.exe and Excel thus numeric seperator on
the
num pad ( . ) will now give a , if this is the system setting

regards

and thanks to all of you for thinking with me to solve this problem

regards

Michel Posseth




M. Posseth said:
Thank you Cor,

I am happy that you understand the problem :)


i have just found a workaround that unfortanitly is not exactly what i
want

if i add this key to the registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,33,00,53,00,00,00,00,00

it works great , however waht if the user changes his settings to for
instance US settings ?? well the dot will then still produce a , so he
needs
to remove the registry key

also a problem is that the user should log off and log on before the
added
key takes effect

it would be much nicer if there is a way to simulate the behavior on
program
start and remove it on program end

or as you mentioned if it is possible to trap the key events on certain
columns in the datagridview and change the numeric dot for a comma this
would be nice , overall trapping wouldn`t work as it must be possible to
enter in a text column in the datagrid M. Posseth and in the column
besides
it 8,99

where the dot after M. is made with >. key and the 8,99 is made
with
the del. key ofcourse it is no problem if del. key creates in the
first
column a . and in the second wich holds numeric values creates a ,

regards

Michel Posseth







Cor Ligthert said:
Michel,

I thought trying to to this problem for you today, I am not sure if I
have
time for that because I go out in some minutes.

It would be based on the fact that you can cast a textbox in a datagrid
and
use its events.

I would use the keyup event and watch if the value is a dot and replace
that
than by a comma and a comma by a dot. (You have than to play with the
selected position and things like that, but I assume that you know
that,
there are plenty of samples in this newsgroup about the numeric textbox
and
in fact do you have to extend that).

I had the idea that I did something before.

Cor
 
G

Guest

Cor

what is the advantage of using the key up event in contradiction to the key
down event ???




Cor Ligthert said:
Michel,

If you use the key up event it is mostly even more simple.

Cor

M. Posseth said:
Sometimes the solution can be so simple ,,, you just have to see it


so for all you outta there with us keyboards in european country`s ( like
it
is the standard in the Netherlands )

take a form set it`s keypreview property to true

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Decimal AndAlso
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator =
"," Then
e.SuppressKeyPress = True
My.Computer.Keyboard.SendKeys(","c)
End If

End Sub

now it works exactly as calc.exe and Excel thus numeric seperator on
the
num pad ( . ) will now give a , if this is the system setting

regards

and thanks to all of you for thinking with me to solve this problem

regards

Michel Posseth




M. Posseth said:
Thank you Cor,

I am happy that you understand the problem :)


i have just found a workaround that unfortanitly is not exactly what i
want

if i add this key to the registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,33,00,53,00,00,00,00,00

it works great , however waht if the user changes his settings to for
instance US settings ?? well the dot will then still produce a , so he
needs
to remove the registry key

also a problem is that the user should log off and log on before the
added
key takes effect

it would be much nicer if there is a way to simulate the behavior on
program
start and remove it on program end

or as you mentioned if it is possible to trap the key events on certain
columns in the datagridview and change the numeric dot for a comma this
would be nice , overall trapping wouldn`t work as it must be possible to
enter in a text column in the datagrid M. Posseth and in the column
besides
it 8,99

where the dot after M. is made with >. key and the 8,99 is made
with
the del. key ofcourse it is no problem if del. key creates in the
first
column a . and in the second wich holds numeric values creates a ,

regards

Michel Posseth







:

Michel,

I thought trying to to this problem for you today, I am not sure if I
have
time for that because I go out in some minutes.

It would be based on the fact that you can cast a textbox in a datagrid
and
use its events.

I would use the keyup event and watch if the value is a dot and replace
that
than by a comma and a comma by a dot. (You have than to play with the
selected position and things like that, but I assume that you know
that,
there are plenty of samples in this newsgroup about the numeric textbox
and
in fact do you have to extend that).

I had the idea that I did something before.

Cor
 
C

Cor Ligthert [MVP]

Michel,

See it yourself what information you get when using the e. It is already
done information.

The moment itself is from no influence; if a key is pushed down it comes
mostly from itself again up.

I also never the e.suppress etc.

Cor

M. Posseth said:
Cor

what is the advantage of using the key up event in contradiction to the
key
down event ???




Cor Ligthert said:
Michel,

If you use the key up event it is mostly even more simple.

Cor

M. Posseth said:
Sometimes the solution can be so simple ,,, you just have to see it


so for all you outta there with us keyboards in european country`s (
like
it
is the standard in the Netherlands )

take a form set it`s keypreview property to true

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Decimal AndAlso
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator
=
"," Then
e.SuppressKeyPress = True
My.Computer.Keyboard.SendKeys(","c)
End If

End Sub

now it works exactly as calc.exe and Excel thus numeric seperator on
the
num pad ( . ) will now give a , if this is the system setting

regards

and thanks to all of you for thinking with me to solve this problem

regards

Michel Posseth




:

Thank you Cor,

I am happy that you understand the problem :)


i have just found a workaround that unfortanitly is not exactly what i
want

if i add this key to the registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,33,00,53,00,00,00,00,00

it works great , however waht if the user changes his settings to for
instance US settings ?? well the dot will then still produce a , so he
needs
to remove the registry key

also a problem is that the user should log off and log on before the
added
key takes effect

it would be much nicer if there is a way to simulate the behavior on
program
start and remove it on program end

or as you mentioned if it is possible to trap the key events on
certain
columns in the datagridview and change the numeric dot for a comma
this
would be nice , overall trapping wouldn`t work as it must be possible
to
enter in a text column in the datagrid M. Posseth and in the column
besides
it 8,99

where the dot after M. is made with >. key and the 8,99 is made
with
the del. key ofcourse it is no problem if del. key creates in
the
first
column a . and in the second wich holds numeric values creates a ,

regards

Michel Posseth







:

Michel,

I thought trying to to this problem for you today, I am not sure if
I
have
time for that because I go out in some minutes.

It would be based on the fact that you can cast a textbox in a
datagrid
and
use its events.

I would use the keyup event and watch if the value is a dot and
replace
that
than by a comma and a comma by a dot. (You have than to play with
the
selected position and things like that, but I assume that you know
that,
there are plenty of samples in this newsgroup about the numeric
textbox
and
in fact do you have to extend that).

I had the idea that I did something before.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top