C# Event Handlers

前端 未结 4 1211
Happy的楠姐
Happy的楠姐 2021-01-17 23:32

How can I check in C# if button.Click event has any handlers associated? If (button.Click != null) throws compile error.

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 23:43

    EventDescriptor e = TypeDescriptor.GetEvents(yourObject).Find("yourEventName", true);

提交回复
热议问题