public partial class Form1 : Form
{
/// <summary>
/// 定义事件
/// </summary>
public event EventHandler TestEvent;
public Form1()
{
InitializeComponent();
//事件绑定方法
TestEvent+=new EventHandler(TestClass_TestEvent);
}
public void Test()
{
///触发事件
TestEvent(this, new EventArgs());
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TestClass_TestEvent(object sender, EventArgs e)
{
MessageBox.Show("时间绑定的方法执行");
}
private void button1_Click(object sender, EventArgs e)
{
Test();
}