How to remove all event handlers from an event

后端 未结 18 1598
再見小時候
再見小時候 2020-11-22 01:20

To create a new event handler on a control you can do this

c.Click += new EventHandler(mainFormButton_Click);

or this

c.Cli         


        
18条回答
  •  抹茶落季
    2020-11-22 01:53

    Stephen has right. It is very easy:

    public event EventHandler les_graph_doivent_etre_redessines;
    public void remove_event()
    {
        if (this.les_graph_doivent_etre_redessines != null)
        {
            foreach (EventHandler F_les_graph_doivent_etre_redessines in this.les_graph_doivent_etre_redessines.GetInvocationList())
            {
                this.les_graph_doivent_etre_redessines -= F_les_graph_doivent_etre_redessines;
            }
        }
    }
    

提交回复
热议问题