清除控件某个事件的所有响应函数
作者:互联网
public void ClearEvent(System.Windows.Forms.Control control, string eventName) { if (control == null) return; try { Type cType = control.GetType(); EventInfo ei = cType.GetEvent( eventName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (ei == null) return; FieldInfo fi = ei.DeclaringType.GetField(eventName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) fi.SetValue(control, null); } catch { } }
标签:control,控件,ei,清除,eventName,BindingFlags,响应函数,fi,null 来源: https://www.cnblogs.com/sinceret/p/12909872.html