Export (0) Print
Expand All

How to: Set Smartphone Input Modes

You can set the input mode for a TextBox in a Smartphone application to ABC, T9, and numeric input modes as defined by the InputMode enumeration. The InputModeEditor class provides access to Smartphone input methods for entering text.

The AlphaCurrent mode is the preferred input mode value for text boxes used for alpha characters. This mode matches the mode selected by holding down the star (*) key on the Smartphone.

You cannot use InputModeEditor to explicitly change casing settings for alpha input modes. However, the alpha input mode used (T9 or ABC) are retained by the AlphaCurrent input mode when set with the star key.

You can only use InputModeEditor on a Smartphone, and only with a TextBox control.

The following code example shows setting the input mode on three text boxes: Name, Phone, and City. The Name and City text boxes are set with the AlphaCurrent input mode and the Phone text box is set with the Numeric input mode.

To observe how AlphaCurrent works, perform the following procedure:

  1. With the Name text box selected, hold down the star key and enter text using either the T9 or ABC input modes.

  2. Enter text in the City text box. Note that the input mode is the same as the Name text box.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;

public class Form1 : System.Windows.Forms.Form
{
 private System.Windows.Forms.MainMenu mainMenu1;
 private System.Windows.Forms.MenuItem mi1;

 // Text box for name. 
 private System.Windows.Forms.TextBox textBox1;
 // Text box for phone number. 
 private System.Windows.Forms.TextBox textBox2;
 // Text box for city. 
 private System.Windows.Forms.TextBox textBox3;

 // Labels for name, phone, and city 
 private System.Windows.Forms.Label label1;
 private System.Windows.Forms.Label label2;
 private System.Windows.Forms.Label label3;

 public Form1()
 {

  InitializeComponent();

  // Add a menu to close the application.
  mi1 = new MenuItem();
  mainMenu1.MenuItems.Add(mi1);
  mi1.Click +=new EventHandler(mi1_Click);
  mi1.Text = "Done";

  // Set input mode for name text box to AlphaCurrent.
  InputModeEditor.SetInputMode(textBox1, InputMode.AlphaCurrent);

  // Set input mode for phone number text box to Numeric.
  InputModeEditor.SetInputMode(textBox2, InputMode.Numeric);

  // Set input mode for city text box to AlphaCurrent.
  InputModeEditor.SetInputMode(textBox3, InputMode.AlphaCurrent);


 }

 protected override void Dispose( bool disposing )
 {
  base.Dispose( disposing );
 }

 private void InitializeComponent()
 {
  this.mainMenu1 = new System.Windows.Forms.MainMenu();

  this.mainMenu1 = new System.Windows.Forms.MainMenu();
  this.textBox1 = new System.Windows.Forms.TextBox();
  this.textBox2 = new System.Windows.Forms.TextBox();
  this.textBox3 = new System.Windows.Forms.TextBox();

  this.label1 = new System.Windows.Forms.Label();
  this.label2 = new System.Windows.Forms.Label();
  this.label3 = new System.Windows.Forms.Label();
  // 
  // textBox1 
  // 
  this.textBox1.Location = new System.Drawing.Point(64, 8);
  this.textBox1.Size = new System.Drawing.Size(104, 25);
  this.textBox1.Text = "";
  // 
  // textBox2 
  // 
  this.textBox2.Location = new System.Drawing.Point(64, 40);
  this.textBox2.Size = new System.Drawing.Size(104, 25);
  this.textBox2.Text = "";
  // 
  // textBox3 
  // 
  this.textBox3.Location = new System.Drawing.Point(64, 72);
  this.textBox3.Size = new System.Drawing.Size(104, 25);
  this.textBox3.Text = "";
  // 
  // label1 
  // 
  this.label1.Location = new System.Drawing.Point(8, 8);
  this.label1.Size = new System.Drawing.Size(56, 22);
  this.label1.Text = "Name";
  // 
  // label2 
  // 
  this.label2.Location = new System.Drawing.Point(8, 40);
  this.label2.Size = new System.Drawing.Size(56, 22);
  this.label2.Text = "Phone";
  // 
  // label3 
  // 
  this.label3.Location = new System.Drawing.Point(8, 72);
  this.label3.Size = new System.Drawing.Size(56, 22);
  this.label3.Text = "City";
  // 
  // Form1 
  // 
  this.Controls.Add(this.textBox1);
  this.Controls.Add(this.textBox2);
  this.Controls.Add(this.textBox3);
  this.Controls.Add(this.label1);
  this.Controls.Add(this.label2);
  this.Controls.Add(this.label3);
  this.Menu = this.mainMenu1;
  this.Text = "Input Mode Demo";

 }

 static void Main()
 {
  Application.Run(new Form1());
 }

 private void mi1_Click(object sender, EventArgs e)
 {
  this.Close();
 }
}

This example requires references to the following namespaces:

Community Additions

ADD
Show:
© 2014 Microsoft