如题,换句话说,只要当前窗体激活的控件变化了就可以触发的事件,有这样的事件么?

解决方案 »

  1.   

    this.ActiveControl可以得到当前有焦点的控件,但是似乎没有它更改的事件或者你继承窗体,重写该属性,在set的时候触发你的事件
      

  2.   


    重写过这个属性,没有用,好像.NET调用,这个属性只是用到时候,会执行Get,SET不执行的!
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication26
    {
        public partial class Form1 : Form
        {        public Form1()
            {
                InitializeComponent();            SetEnterEvent(this.Controls);
            }        void SetEnterEvent(Control.ControlCollection CC)
            {
                foreach (Control C in CC)
                {
                    C.Enter += new EventHandler(C_Enter);
                    SetEnterEvent(C.Controls);
                }
            }        void C_Enter(object sender, EventArgs e)
            {
                MessageBox.Show(((Control)sender).Name + "被激活");
            }
        }
    }
      

  4.   


    完全可以实现!不过是为窗体所有控件添加了Enter事件,看还有没有别的办法!