可能我描述的不太清楚,就是怎么才能我查公布出去TextBox.Leave事件

解决方案 »

  1.   

    public delegate void BeginEventHandler(string text);class  里面
            public event BeginEventHandler OnBegin;
    触发             if (OnBegin != null)
                    OnBegin("Begin.");  
      

  2.   

    //假设CTR是你那个复合类:        public class CTR{
                private TextBox txt;
                private Button btn;
                public delegate void LeaveHandler(object sender,EventArgs e);
                public event LeaveHandler Leave;
                public CTR(TextBox txt, Button btn)
                {
                    this.btn = btn;
                    this.txt = txt;
                    txt.Leave += new EventHandler(txt_Leave);
                }            void txt_Leave(object sender, EventArgs e)
                {
                    this.OnLeave(e);
                }
                void OnLeave(EventArgs e)
                {
                    if (Leave != null) {
                        Leave(this, e);
                    }
                }
            }//使用示范,先在form1上画textBox1和button1    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                CTR ctr = new CTR(textBox1, button1);
                ctr.Leave += new CTR.LeaveHandler(txt_Leave);
            }
            void txt_Leave(object sender, EventArgs e)
            {
                MessageBox.Show("123");
            }
        }