动态添加控件
combox.SelectedIndexChanged += new EventHandler1(ComBoxSelectedIndexChanged);
ComBoxSelectedIndexChanged怎么作为参数传递?

解决方案 »

  1.   

    ComBoxSelectedIndexChanged是你已经写好的一个方法啊!
    或者用一个方法返回起对应的EventHandler
      

  2.   

    ComBoxSelectedIndexChanged是你自定义的方法,方法里的参数与你定义委托的参数个数和类型一致
      

  3.   

    private void button1_Click(object sender, EventArgs e)
            {
                //获取控件名称
                string ControlName = (sender as Button).Name;            //调用事件
                StartMethod(this.GetType().GetMethod("事件名", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), "控件名称", EventArgs.Empty);            //调用方法
                StartMethod(this.GetType().GetMethod("方法名"), "参数");
            }        #region StartMethod
            /// <summary>
            /// 重起方法
            /// </summary>
            /// <param name="Method">方法</param>
            /// <param name="param">参数</param>
            public void StartMethod(System.Reflection.MethodInfo Method, params object[] param)
            {
                Method.Invoke(this, param);
            }
            #endregion
      

  4.   

    楼上的方法不行,我是想ComBoxSelectedIndexChanged这个事件在其他类里实现
    public void start(参数)
    {
       combox.SelectedIndexChanged += new EventHandler1(ComBoxSelectedIndexChanged);
    }
    这个只是一个方法,其他都可以调用的
      

  5.   

    http://www.rainsts.net/article.asp?id=395
      

  6.   

    public class A
    {
        public static void ComBoxSelectedIndexChanged();
    }public void start(参数)
    {
       combox.SelectedIndexChanged += new EventHandler1(A.ComBoxSelectedIndexChanged);
    }
      

  7.   

    多个类中有委托方法.还是要在多类中用委托?
    如果用得话,EventHandler1静态不知道行不行
      

  8.   

    窗体的参数传递,我在里面写了实现例子,
    http://blog.csdn.net/zhzuo/archive/2006/05/05/708941.aspx#sec5