I need to working with combobox SelectedIndexChanged event, but in some cases I want when click button cancel SelectedIndexChanged event or code related to this event stop working ?
Asked
Active
Viewed 4,596 times
4 Answers
4
ComboBox comboBox = new ComboBox();
Subscribe to SelectedIndexChanged event
comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
Use below code to unsubscribe the SelectedIndexChanged event
comboBox.SelectedIndexChanged -= comboBox_SelectedIndexChanged;

Soner Gönül
- 97,193
- 102
- 206
- 364

Ramashankar
- 1,598
- 10
- 14
1
There are number of options
- You can unsubscribe the event temporarily
- You can maintain a flag to check whether you need to process it or not.

Sriram Sakthivel
- 72,067
- 7
- 111
- 189
1
- You can disable/enable the combobox, on the basis of button click
- You can unsubscribe the
SelectedIndexChanged
as told by @Ramashankar - Maintain a flag to check whether event has to be executed or not

user247702
- 23,641
- 15
- 110
- 157

andy
- 5,979
- 2
- 27
- 49
0
You can unsubscribe the events like the below upon clicking on the button:
combo1.SelectedIndexChanged -= combo1_SelectedIndexChanged;

Prasanna
- 760
- 2
- 6
- 16