public Form1()
        {
            InitializeComponent();            foreach (Control control in this.Controls)
            {
                control.Click += new EventHandler(control_Click);
            }
            
        }
        private void InitializeComponent()
        {
          ....
          this.button1.Click += new System.EventHandler(this.button1_Click);
        }
   
        void control_Click(object sender, EventArgs e)
        {
           MessageBox.Show("aaaaa");
           
        }   
        private void button1_Click(object sender, EventArgs e)
        {
            
            MessageBox.Show("bbbb"); 
        }怎样实现先提示aaaa, 然后再出现bbbb.

解决方案 »

  1.   

    void control_Click(object sender, EventArgs e)
      {
      
     MessageBox.Show("bbbb");    }    
      private void button1_Click(object sender, EventArgs e)
      {
        MessageBox.Show("aaaaa");
        
     
      }
      

  2.   

    怎样实现先提示aaaa, 然后再出现bbbb.
    不用怎么实现,你的btn是点了后才弹出提示框,而control也是点了后才弹出提示框,不存在谁先谁后,只有点了才触发
      

  3.   

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();            foreach (Control ctrl in this.Controls)
                {                PropertyInfo propertyInfo = ctrl.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance);
                    EventHandlerList handlerList = (EventHandlerList)propertyInfo.GetValue(ctrl, null);                FieldInfo field = typeof(Control).GetField("EventClick", BindingFlags.NonPublic| BindingFlags.Static);
                    Delegate d = handlerList[field.GetValue(null)];
                    ctrl.Click -= (EventHandler)d;                d=Delegate.Combine(new EventHandler(this.ctrl_Click),d);
                    ctrl.Click += (EventHandler)d;
                }
            }        void ctrl_Click(object sender, EventArgs e)
            {
                MessageBox.Show("aaaaa");
            }        private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("bbbb");
            }
        }