views:

1006

answers:

1

Hello everybody!

For a project I built a custom DataGridView column which contains NumericUpDown controls. It is implemented similar to the suggestion from Microsoft

The column works fine under Windows XP. It accepts the entered digits and decimal separator. Under Windows Vista I have the odd problem that the control only accepts the decimal separator entered by the numeric keypad but not from the keyboard main block.

I have to add that I work with German (Switzerland) culture settings under Windows Vista and the German (Switzerland) keyboard layout is activated. The decimal separator in Switzerland is .

Someone has an idea for the reason and maybe a solution? Thank you very much!

Michael

Edit: I found the solution to my problem.

  1. To clarify the situation a little bit more. The NumericUpDown control I use implements IDataGridViewEditingControl and inherits from NumericUpDown. Because of IDataGridViewEditingControl I implement the method EditingControlWantsInputKey. And in the implementation of this method I found my mistake or what went wrong.

  2. In the method I inspected the entered keys and decided if the control had to handle it. But for the decimal separator I only expected Keys.Decimal. In my special (wrong) case the key could not be matched. What was missing was to look for Keys.OemPeriod too. And that was the fix.

A: 

Can you please paste your OnKeyDown and/or OnKeyPress code? At least the relevant key-filtering code. It will make be easier to spot out any problems.

BTW, I normally use both a British English and Brazilian Portuguese keyboards, so I've had my share of these issues. That kind of forces you to become a localization expert :)

Edit: Oh, sorry, just re-read and understood you are using the stock NumericUpDown control. Can you point me out to the column code so I can try it here? Probably the locale is not getting set for the control, and you'll have to manually do it at some point.

dguaraglia
Thank you very much for you help! I found the responsible code and fixed it (see the edited part in the question).
Mil