views:

362

answers:

2

I have a windows mobile app developed using the .NET CF 3.5. I'd like to allow only numbers to be entered in a particular text box when it has focus... I.e. programmatically press the FN key so the user can simply type the numbers on the keypad w/o having to hold the FN key.

+1  A: 

This is a blogpost in 2.0 but i strongly believe it will work for you in 3.5

http://www.ceveni.com/2008/11/programmatically-press-keys-in-windows.html

It doesn't list the FN key but you can catch it in your application read it's event code and use it.

A problem you may come up against is the case where pressing the FN key multiple times takes you to different states, ie toggle back and forth to alpha and numeric modes.

Konstantinos
A: 

I code in C, so I'm not 100% sure about NET CF, but if you are using a standard windows control, you need to set the attribute ES_NUMBER for an input field and this will allow only numerical input. On phones with number keys overlaid on top of letter keys, this will cause those keys to produce only numbers without having to explicitly press the ALT button.

BitBank