ToolStripItem item = sender as ToolStripItem;
PropertyInfo propertyInfo = (typeof (ToolStripItem)).GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
EventHandlerList eventHandlerList = (EventHandlerList) propertyInfo.GetValue(item, null);
FieldInfo fieldInfo = (typeof(ToolStripItem)).GetField ("EventClick", BindingFlags.Static | BindingFlags.NonPublic);
Delegate d = eventHandlerList[fieldInfo.GetValue(null)];
if (d != null)
{
foreach (Delegate temp in d.GetInvocationList())
{
//這裡已經取得了所有Click事件綁定的處理程序,可以做一些事情。例如下面 的代碼是撤銷所有的事件注冊
item.Click -= temp as EventHandler;
}
}