这不是太难做到吧,你建立的form,添加按钮,按钮添加单击方法,设为PUBLIC,外面调用的时候,先实例化form,通过form调用按钮的方法,我的理解!如果不对就抱歉了!

解决方案 »

  1.   

    TestFormDll.showDataForm.csprivate EventHandlerList _eventHandler = new EventHandlerList();
            private readonly object _eOnClick = new object();        public event EventHandler OnTextClick
            {
                add { _eventHandler.AddHandler(_eOnClick, value); }
                remove { _eventHandler.RemoveHandler(_eOnClick, value); }
            }        private void FireOnClick()
            {
                EventHandler handler = _eventHandler[_eOnClick] as EventHandler;
                if (null != handler)
                    handler(this, new EventArgs());
            }        private void textBox1_Click(object sender, EventArgs e)
            {
                FireOnClick();
            }
      

  2.   

    调用代码
    Assembly _Assembly = Assembly.Load("TestFormDll");
                Type _Type = _Assembly.GetType("TestFormDll.showDataForm");
                Form _Form = (Form)Activator.CreateInstance(_Type);
                System.Reflection.EventInfo _EventInfo = _Type.GetEvent("OnTextClick");
                _EventInfo.AddEventHandler(_Form, new EventHandler(Target));
                _Form.ShowDialog();
      

  3.   

    void Target(object sender, EventArgs e)
            {
                MessageBox.Show("Hello Jimmy");
            }
      

  4.   

    TestFormDll.showDataForm f2= new TestFormDll.showDataForm();
                MethodInfo m = f2.GetType().GetMethod("事件的名字", BindingFlags.NonPublic|BindingFlags.Instance);
                m.Invoke(f2, new object[] { 参数1, 参数2 });
    那两个是事件的参数,放null也是可以的,看情况吧
      

  5.   


    我测试过你的代码,为什么事件Target里面的sender总是为空?
         
          void Target(object sender, EventArgs e)
            {
             
                MessageBox.Show("Hello Jimmy");
                //TextBox tt = sender as TextBox;
                //MessageBox.Show(tt.Text  );
            }
      

  6.   


    我测试过你的代码,为什么事件Target里面的sender总是为空?
         
          void Target(object sender, EventArgs e)
            {
             
                MessageBox.Show("Hello Jimmy");
                //TextBox tt = sender as TextBox;
                //MessageBox.Show(tt.Text  );
            }TextBox tt = sender as TextBox;
    我晕,你想多了~~~
    上面的代码你没看懂
      

  7.   

    1.oh,这个....事件方面我比较菜,能解释一下吗,现在的情况是把dll里面textbox控件的 Click 事件反射到调用的app,然后不同的app可以做对应的处理,你给我的代码不是这样吗?2. Form _Form = (Form)Activator.CreateInstance(_Type);
    我使用 _Form 访问不了dll里面的其他 public 成员,例如我还在 showDataForm 里面定义了一个 public string GetStrTest = ""; 但是无法透过 _Form. 访问.