Compact Framework - Setting the input mode to “numeric”
For certain fields in my application, I want to set the input mode (usually to numeric – eg for the distance, final mileage and date fields numeric makes most sense). This makes a *big* difference to the experience on the SmartPhone so take the time and trouble to set input mode where it makes sense. This requires a bit of interop as the Compact Framework does not provide a direct mechanism to do this. The following MSDN articles show you how to change the input mode.
- .NET Compact Framework FAQ - .NET Compact Framework (General) (search for “input mode”)
- Crafting Smartphone User Interfaces Using .NET Compact Framework
I adopted the latter of the two approaches which wraps up the interop in a SetInputMode method so you can simply do something like:
InputMode.SetInputMode(txtDistance, InputMode.Mode.Numbers);
And that will set the input mode of the txtDistance TextBox to numeric. Very neat.