闪客动漫天地论坛

首页 » 设计乐园 » 彩信制作乐园 » Control.Events 属性
女女 - 2007-6-19 9:15:00
获取控件的事件处理程序委托列表。此属性为只读。

命名空间:System.Web.UI
程序集:System.Web(在 system.web.dll 中)

语法
Visual Basic(声明)
Protected ReadOnly Property Events As EventHandlerList

Visual Basic(用法)
Dim value As EventHandlerList

value = Me.Events


C#
protected EventHandlerList Events { get; }

C++
protected:
property EventHandlerList^ Events {
    EventHandlerList^ get ();
}

J#
/** @property */
protected EventHandlerList get_Events ()


JScript
protected function get Events () : EventHandlerList





属性值
事件处理程序委托的列表。
备注
此属性属于 EventHandlerList 类型,它使用线性搜索算法在委托列表中查找项。线性搜索算法在处理大量项时是低效的。因此,当列表很大时,使用此属性查找项的速度会很慢。

示例
下面的示例创建一个名为 Click 的事件,当从页面调用此事件时,它向控件的 EventHandlerList 集合中添加或从中删除处理程序。

注意  该示例优化控件如何从该控件维护的事件列表中添加和删除事件。如果您创建自定义控件并想定义事件,请使用与此类似的代码。该技术可以在 C# 中使用,但不能在 Visual Basic 中使用。

C#  复制代码
// Create an event that adds and removes handlers from the
// Control.Events collection when this event is called from
// a participating page.
public event EventHandler Click {
    add {
        Events.AddHandler(EventClick, value);
    }
    remove {
        Events.RemoveHandler(EventClick, value);
    }
}


J#  复制代码
// Create an event that adds and removes handlers from the
// Control.Events collection when this event is called from
// a participating page.



平台
Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
 1 
查看完整版本: Control.Events 属性