obj.Click += new EventHandler(btn_Click);
obj.Press += new EventHandler(btn_Press);
obj.Connect += new EventHandler(btn_Connect);

解决方案 »

  1.   

    public static Delegate[] GetObjectEventList(object p_Object, string p_EventName, Type p_EventType)
      {
      PropertyInfo _PropertyInfo = p_Object.GetType().GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
      if (_PropertyInfo != null)
      {
      object _EventList = _PropertyInfo.GetValue(p_Object, null);
      if (_EventList != null && _EventList is EventHandlerList)
      {
      EventHandlerList _List = (EventHandlerList)_EventList;
      FieldInfo _FieldInfo = p_EventType.GetField(p_EventName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
      if (_FieldInfo == null) return null;
      Delegate _ObjectDelegate = _List[_FieldInfo.GetValue(p_Object)];
      if (_ObjectDelegate == null) return null;
      return _ObjectDelegate.GetInvocationList();
      }
      }
      return null;
      }