0

他のクラスで同じデリゲートを使用することは可能ですか?

コピー コードを使用せずに、同じデリゲートを他のコントロールに実装したいのですが、このデリゲートを自分のオブジェクトにリンクできますか?

私はこれを試しました:

public MyOtherControl(Control OtherControl)
  : base()
{

  EventInfo _combo_key_press_event;
  Type _combo_key_press_delegate;


  _combo_key_press_event = this.GetType().GetEvent("KeyPress");
   // KeyPressEventHandler  
  _combo_key_press_delegate = _combo_key_press_event.EventHandlerType;     

  MethodInfo miHandler = OtherControl.GetType().GetMethod("OnKeyPress",BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.CreateInstance);

  Delegate.CreateDelegate(_combo_key_press_delegate, this, miHandler);

}

それでも、常に ArgumentException というメッセージが表示されますError binding to target method

4

0 に答える 0