代码
事件定义:
/// <summary>
/// 自定义事件委托
/// </summary>
public delegate void ExpertListCommandEventHandler(object sender, Professor.UserControls.ExpertListCommandEventArgs e);
/// <summary>
/// 定义事件
/// </summary>
public event ExpertListCommandEventHandler Command;
/// <summary>
/// 引发事件的方法
/// </summary>
public void RaiseCommandEvent(Professor.UserControls.ExpertListCommandEventArgs e)
{
this.Command(this, e);
}
事件特性(参数)类:必须继承自EventArgs. 可包含多种类型数据.
public class CommandEventArgs: System.EventArgs
{
private string commandName;
/// <summary>
/// 命令名称.
/// </summary>
public string CommandName
{
get
{
return this.commandName;
}
set
{
this.commandName = value;
}
}
private int id;
/// <summary>
/// 操作对象: 被操作的专家ID数列
/// </summary>
public int Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
}