如何与QUOT;未设置"事件事件、QUOT

2023-09-03 05:25:15 作者:凉城冷巷樱花雨

如果我有一个组合框单击事件在designer.cs页,然后在程序运行中的某些点设置的基础上,一定条件下,我不再想组合框Click事件进行设置,我该怎么办未设置吗?我试着comboboxname.Click + = null,并且我已经尝试将其设置到另一个虚拟函数什么也不做......没有工作。

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 Click event to be set, how do I "unset" it? I've tried comboboxname.Click += null and I've tried setting it to another dummy function that does nothing...neither works.

推荐答案

设置:

comboBox.Click += EventHandler;

取消设置:

comboBox.Click -= EventHandler;