日期:2014-05-17 浏览次数:20853 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public virtual void button1_Click(object sender, EventArgs e) //祖先窗口的事件
{
MessageBox.Show("祖先的事件!。");
}
}
}
//继承自Form1窗口
namespace WindowsApplication1
{
public partial class Form2 : WindowsApplication1.Form1
{
public Form2()
{
InitializeComponent();
}
public override void button1_Click(object sender, EventArgs e)//重写了原来的事件
{
MessageBox.Show("继承后的事件!");//这个事件为什么会触发两次????
}
}
}