Control.ImeModeChanged Événement

Définition

Se produit quand la propriété ImeMode a été modifiée.

public:
 event EventHandler ^ ImeModeChanged;
public event EventHandler ImeModeChanged;
member this.ImeModeChanged : EventHandler 
Public Custom Event ImeModeChanged As EventHandler 

Type d'événement

EventHandler

Exemples

L’exemple de code suivant est un gestionnaire d’événements qui est exécuté lorsque la Text valeur de propriété change. La Control classe a plusieurs méthodes avec le nom pattern PropertyNameChanged qui sont déclenchés lorsque la valeur PropertyName correspondante change (PropertyName représente le nom de la propriété correspondante).

L’exemple de code suivant modifie l’affichage ForeColor des TextBox données monétaires. L’exemple convertit le texte en nombre décimal et change la ForeColor Color.Red valeur si le nombre est négatif et Color.Black si le nombre est positif. Cet exemple nécessite que vous ayez un qui contient un Form TextBox.

private:
   void currencyTextBox_TextChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         // Convert the text to a Double and determine if it is a negative number.
         if ( Double::Parse( currencyTextBox->Text ) < 0 )
         {
            // If the number is negative, display it in Red.
            currencyTextBox->ForeColor = Color::Red;
         }
         else
         {
            // If the number is not negative, display it in Black.
            currencyTextBox->ForeColor = Color::Black;
         }
      }
      catch ( Exception^ ) 
      {
         // If there is an error, display the text using the system colors.
         currencyTextBox->ForeColor = SystemColors::ControlText;
      }
   }
private void currencyTextBox_TextChanged(object sender, EventArgs e)
{
   try
   {
      // Convert the text to a Double and determine if it is a negative number.
      if(double.Parse(currencyTextBox.Text) < 0)
      {
         // If the number is negative, display it in Red.
         currencyTextBox.ForeColor = Color.Red;
      }
      else
      {
         // If the number is not negative, display it in Black.
         currencyTextBox.ForeColor = Color.Black;
      }
   }
   catch
   {
      // If there is an error, display the text using the system colors.
      currencyTextBox.ForeColor = SystemColors.ControlText;
   }
}
Private Sub currencyTextBox_TextChanged(sender As Object, _ 
  e As EventArgs) Handles currencyTextBox.TextChanged
   Try
      ' Convert the text to a Double and determine if it is a negative number.
      If Double.Parse(currencyTextBox.Text) < 0 Then
         ' If the number is negative, display it in Red.
         currencyTextBox.ForeColor = Color.Red
      Else
         ' If the number is not negative, display it in Black.
         currencyTextBox.ForeColor = Color.Black
      End If
   Catch
      ' If there is an error, display the text using the system colors.
      currencyTextBox.ForeColor = SystemColors.ControlText
   End Try
End Sub

Remarques

Cet événement est déclenché si la ImeMode propriété est modifiée par une modification par programmation ou par interaction.

Les contrôles qui ne prennent pas en charge les gestionnaires de méthodes d’entrée ne déclenchent jamais cet événement.

Pour plus d'informations sur la gestion des événements, voir gestion et déclenchement d’événements.

S’applique à

Voir aussi