I entered the topic directly and became confused for one afternoon.
Functions to be implemented:
Checkedlistbox control of winform
Click "all" and select all. However, if you click too fast, the above phenomenon will occur. The following options are not selected.
The Code is as follows:
Private void clbsaledept_selectedindexchanged (Object sender, eventargs e) {checkedlistbox cb = sender as checkedlistbox; If (cb = NULL | CB. selectedindex <0) {return;} // if you click "select all" If (CB. selectedindex = 0) {for (INT I = 1; I <CB. items. count; I ++) {console. writeline (CB. getitemchecked (0); CB. setitemchecked (I, CB. getitemchecked (0) ;}} else {If (! CB. getitemchecked (CB. selectedindex) {// when one of the other options is not selected, deselect "select all" CB. setitemchecked (0, false);} else if (! CB. getitemchecked (0) & CB. selecteditems. count> = (CB. items. count-1) {// when all others are selected, select "select all" CB. setitemchecked (0, true );}}}
I can't see any problems in the code.
After writing the log, it is concluded that when you click "select all" quickly, this event is not entered every time.
The problem that best thinking cannot ride elder sister-is it a control bug?