淺析Linux下准確掌握時光的函數。本站提示廣大學習愛好者:(淺析Linux下准確掌握時光的函數)文章只能為提供參考,不一定能成為您想要的結果。以下是淺析Linux下准確掌握時光的函數正文
本文實例講述了WinForm完成移除控件某個事宜的辦法,供年夜家參考自創一下。詳細功效代碼以下:
重要功效部門代碼以下:
/// <summary> /// 移除控件某個事宜 /// </summary> /// <param name="control">控件</param> /// <param name="eventName">須要移除的控件稱號eg:EventClick</param> public static void RemoveControlEvent(this Control control, string eventName) { FieldInfo _fl = typeof(Control).GetField(eventName, BindingFlags.Static | BindingFlags.NonPublic); if (_fl != null) { object _obj = _fl.GetValue(control); PropertyInfo _pi = control.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance); EventHandlerList _eventlist = (EventHandlerList)_pi.GetValue(control, null); if (_obj != null && _eventlist != null) _eventlist.RemoveHandler(_obj, _eventlist[_obj]); } }
應用代碼:
private void WinRemoveControlEventTest_Load(object sender, EventArgs e) { button1.RemoveControlEvent("EventClick"); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("button1_Click"); }