How to “Unset” Event

前端 未结 5 1075
醉酒成梦
醉酒成梦 2021-01-19 15:10

If I have a combobox click event set in the designer.cs page and then at some point during the running of the program, based on some condition, I no longer want the combobox

5条回答
  •  滥情空心
    2021-01-19 16:00

    The reason you cannot use

    comboboxname.Click = null
    

    or

    comboboxname.Click += null
    

    is that the event Click actually contains a list of event handlers. There may be multiple subscribers to your event and to undo subscribing to an event you have to remove only your own event handler. As it has been pointed out here you use the -= operator to do that.

提交回复
热议问题