InputLanguageChangedEventHandler Delegado

Definición

Representa el método que controlará el evento InputLanguageChanged de Form.

public delegate void InputLanguageChangedEventHandler(System::Object ^ sender, InputLanguageChangedEventArgs ^ e);
public delegate void InputLanguageChangedEventHandler(object sender, InputLanguageChangedEventArgs e);
public delegate void InputLanguageChangedEventHandler(object? sender, InputLanguageChangedEventArgs e);
type InputLanguageChangedEventHandler = delegate of obj * InputLanguageChangedEventArgs -> unit
Public Delegate Sub InputLanguageChangedEventHandler(sender As Object, e As InputLanguageChangedEventArgs)

Parámetros

sender
Object

Origen del evento.

e
InputLanguageChangedEventArgs

Objeto InputLanguageChangedEventArgs que contiene los datos del evento.

Ejemplos

En el ejemplo siguiente se crea un nuevo Form y se adjunta un controlador de eventos al InputLanguageChanged evento. Este evento cambia cuando IMEmode cambia el idioma de entrada al japonés.

#using <System.Data.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Data;
public ref class Form1: public System::Windows::Forms::Form
{
private:
   RichTextBox^ rtb;

public:
   Form1()
   {
      rtb = gcnew RichTextBox;
      this->Controls->Add( rtb );
      rtb->Dock = DockStyle::Fill;
      this->InputLanguageChanged += gcnew InputLanguageChangedEventHandler( this, &Form1::languageChange );
   }


private:
   void languageChange( Object^ /*sender*/, InputLanguageChangedEventArgs^ e )
   {
      
      // If the input language is Japanese.
      // set the initial IMEMode to Katakana.
      if ( e->InputLanguage->Culture->TwoLetterISOLanguageName->Equals( "ja" ) )
      {
         rtb->ImeMode = System::Windows::Forms::ImeMode::Katakana;
      }
   }

};

int main()
{
   Application::Run( gcnew Form1 );
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form
{
    RichTextBox rtb = new RichTextBox();
    public Form1()
    {
        this.Controls.Add(rtb);
        rtb.Dock = DockStyle.Fill;
        this.InputLanguageChanged += new InputLanguageChangedEventHandler(languageChange);
    }
    private void languageChange(Object sender, InputLanguageChangedEventArgs e)
    {
        // If the input language is Japanese.
        // set the initial IMEMode to Katakana.
        if (e.InputLanguage.Culture.TwoLetterISOLanguageName.Equals("ja"))
        {
            rtb.ImeMode = System.Windows.Forms.ImeMode.Katakana;
        }
    }
    public static void Main(string[] args)
    {
        Application.Run(new Form1());
    }
}
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data

Public Class Form1
   Inherits System.Windows.Forms.Form
   
   Dim WithEvents rtb As New RichTextBox()
   
   Public Sub New()
      MyBase.New()
      Me.Controls.Add(rtb)
      rtb.Dock = DockStyle.Fill
   End Sub

   Private Sub languageChange( _
      ByVal sender As Object, _
      ByVal e As InputLanguageChangedEventArgs _
   ) Handles MyBase.InputLanguageChanged

      ' If the input language is Japanese.
      ' set the initial IMEMode to Katakana.
      If e.InputLanguage.Culture.TwoLetterISOLanguageName.Equals("ja") = True Then
         rtb.ImeMode = System.Windows.Forms.ImeMode.Katakana
      End If
   End Sub

   Public Shared Sub Main()
      Application.Run(new Form1())
   End Sub

End Class

Comentarios

Cuando se crea un delegado InputLanguageChangedEventHandler, se identifica el método que controlará el evento. Para asociar el evento al controlador, se debe agregar una instancia del delegado al evento. Siempre que se produce el evento, se llama a su controlador, a menos que se quite el delegado.

Para obtener más información sobre los delegados del controlador de eventos, vea Control y generación de eventos.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.

Se aplica a

Consulte también