Condividi tramite


Classe InputModeEditor

Aggiornamento: novembre 2007

Fornisce l'accesso ai metodi di input del dispositivo Smartphone per l'immissione di testo.

Spazio dei nomi:  Microsoft.WindowsCE.Forms
Assembly:  Microsoft.WindowsCE.Forms (in Microsoft.WindowsCE.Forms.dll)

Sintassi

'Dichiarazione
Public NotInheritable Class InputModeEditor
'Utilizzo
Dim instance As InputModeEditor
public sealed class InputModeEditor
public ref class InputModeEditor sealed
public final class InputModeEditor

Note

È possibile impostare la modalità di input solo per un controllo TextBox. Per specificare una modalità di input, specificare uno dei valori dell'enumerazione InputMode. Lo Smartphone supporta le modalità di input ABC, T9 e numerica.

La modalità AlphaCurrent è la modalità di input preferita per le caselle di testo utilizzata per i caratteri alfabetici. Questa modalità corrisponde alla modalità che viene selezionata il tasto asterisco (*) sul dispositivo Smartphone. Non è possibile utilizzare un oggetto InputModeEditor per modificare in modo esplicito le impostazioni per l'utilizzo delle maiuscole e delle minuscole per le modalità di input per i caratteri alfabetici. La modalità di input per i caratteri alfabetici utilizzata (T9 o ABC) viene tuttavia mantenuta dalla modalità di input AlphaCurrent quando viene impostata con il carattere asterisco.

Supportata nei dispositivi Smartphone 2003. L'utilizzo di questa classe per un dispositivo diverso dallo Smartphone o per un controllo diverso da un controllo TextBox ha esito negativo, ma non viene generata alcuna eccezione.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come impostare la modalità di input per tre caselle di testo: Name, Phone e City. Per le caselle di testo Name e City viene impostata la modalità di input AlphaCurrent, mentre per la casella di testo Phone viene impostata la modalità di input Numeric.

Per osservare il funzionamento della modalità di input AlphaCurrent, procedere come segue:

  1. Con la casella di testo Name selezionata, tenere premuto il tasto asterisco e immettere testo utilizzando la modalità di input T9 o ABC.

  2. Immettere testo nella casella di testo City. Si noti che la modalità di input è uguale a quella della casella di testo Name.

Imports System
Imports System.Windows.Forms
Imports Microsoft.WindowsCE.Forms



Public Class Form1
   Inherits System.Windows.Forms.Form
   Private mainMenu1 As System.Windows.Forms.MainMenu
   Private mi1 As System.Windows.Forms.MenuItem

   ' Text box for name.
   Private textBox1 As System.Windows.Forms.TextBox
   ' Text box for phone number.
   Private textBox2 As System.Windows.Forms.TextBox
   ' Text box for city.
   Private textBox3 As System.Windows.Forms.TextBox

   ' Labels for name, phone, and city
   Private label1 As System.Windows.Forms.Label
   Private label2 As System.Windows.Forms.Label
   Private label3 As System.Windows.Forms.Label


   Public Sub New()

      InitializeComponent()

      ' Add a menu to close the application.
      mi1 = New MenuItem()
      mainMenu1.MenuItems.Add(mi1)
      AddHandler mi1.Click, AddressOf 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)
   End Sub



   Protected Overrides Sub Dispose(disposing As Boolean)
      MyBase.Dispose(disposing)
   End Sub


   Private Sub InitializeComponent()
      Me.mainMenu1 = New System.Windows.Forms.MainMenu()

      Me.mainMenu1 = New System.Windows.Forms.MainMenu()
      Me.textBox1 = New System.Windows.Forms.TextBox()
      Me.textBox2 = New System.Windows.Forms.TextBox()
      Me.textBox3 = New System.Windows.Forms.TextBox()

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


   Shared Sub Main()
      Application.Run(New Form1())
   End Sub


   Private Sub mi1_Click(sender As Object, e As EventArgs)
      Me.Close()
   End Sub
End Class
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();
 }
}

Gerarchia di ereditarietà

System.Object
  Microsoft.WindowsCE.Forms.InputModeEditor

Codice thread safe

Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme

Windows Mobile per Smartphone

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Compact Framework

Supportato in: 3.5, 2.0

Vedere anche

Riferimenti

Membri InputModeEditor

Spazio dei nomi Microsoft.WindowsCE.Forms

Altre risorse

Procedura: impostare le modalità di input dello Smartphone