using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GoldCubePos.App
{
public partial class Form1 : Form
{
private delegate void ShowName(object sender);//定义委托
private event ShowName btnclick;//定义事件
//调用的方法
private void ShowButtonName(object sender)
{
Button btn = sender as Button;
if (btn != null)
{
MessageBox.Show("按钮名称是:" + btn.Text);
}
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//System.Diagnostics.Process.Start("http://www.163.com");
MessageBox.Show("我被点击了!!!");
btnclick += ShowButtonName;//订阅事件
btnclick(sender);
}
}
}