我建了个继承自系统Label的基类Class A,然后在构造函数里面定义了A的mouseDown,MouseUp,MouseEnter事件;
现在我想建立一个继承自A的类Class B,同时希望B能够继承A已经定义好的MouseDown事件。
请问各位大大,这个该怎么弄??谢谢......

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication33
    {
        public partial class Form1 : Form
        {        public class A: Label
            {
                protected override void OnMouseDown(MouseEventArgs e)
                {
                    MessageBox.Show("A:点我");
                    base.OnMouseDown(e);
                }
            }
            public class B : A
            {
                protected override void OnMouseDown(MouseEventArgs e)
                {
                    MessageBox.Show("B:点我");
                    base.OnMouseDown(e);
                }
            }        public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                B b = new B();
                this.Controls.Add(b);
                b.Text = "jinjazz";
            }
        }
    }