InputLanguageChangedEventHandler 委托

定义

表示将用来处理 InputLanguageChangedForm 事件的方法。

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)

参数

sender
Object

事件源。

示例

以下示例创建一个新的 Form 并将事件处理程序附加到 事件 InputLanguageChanged 。 当输入语言更改为 IMEmode 日语时,此事件会更改 。

#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

注解

创建 InputLanguageChangedEventHandler 委托时,需要标识将要处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。

有关事件处理程序委托的详细信息,请参阅 处理和引发事件

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

另请参阅