button1_Click(object sender,EventHandler e) orm
{
Button button=(Button)sender;
button.Text="text property has been changed at its event";
}事件
若是一个按钮button1,我点击这个按钮﹕sender就是按鈕﹐因為事件是在按鈕內部触发的。若是要在程序中使用sender,通常情況下你就必須知道sender是哪一个类型的(好比在上面這中情況中必須只要sender的type是Button),而后在转换到那個类型中去﹐這樣你就能够在事件中访问事件发送者的数据it
e是事件参数,也就是说在定义事件的类里定义的那些属性,在某些事件里,e用处不大;
所包含的细节多少,根据各类EventArgs的定义而定,如EventArgs就是一个空值,咱们在VS环境中右键"转到定义处"就能够发现其定义是这样:event
public class EventArgs
{
// 摘要:
// 表示没有事件数据的事件。
public static readonly EventArgs Empty;
// 摘要:
// 初始化 System.EventArgs 类的新实例。
public EventArgs();
}class
// 摘要: // 为 System.Windows.Forms.Control.MouseUp、System.Windows.Forms.Control.MouseDown
// 和 System.Windows.Forms.Control.MouseMove 事件提供数据。
[ComVisible(true)]
public class MouseEventArgs : EventArgs
{
// 摘要:
// 初始化 System.Windows.Forms.MouseEventArgs 类的新实例。
//
// 参数:
// clicks:
// 鼠标按钮曾被按下的次数。
//
// delta:
// 鼠标轮已转动的制动器数的有符号计数。
//
// Y:
// 鼠标单击的 y 坐标(以像素为单位)。
//
// button:
// System.Windows.Forms.MouseButtons 值之一,它指示曾按下的是哪一个鼠标按钮。
//
// x:
// 鼠标单击的 x 坐标(以像素为单位)。
好比在MouseEventArgs的Mouse事件中,能够看到e包括mouse的坐标值等,以供你的程序使用。e参数就是经过这些定义的属性进行调用或输出的,这里咱们就能够调用e.Y或e.X得到具体的参数细节了.cli