How to uncheck disabled checkedlistbox in c# winforms? -


enter image description here

in above image "ug(user group)" row in checkedlistbox enabled property false. how uncheck "ug(user group)" in disabled state.

you can use

checkedlistbox1.setitemchecked(2, false); 

or

checkedlistbox1.setitemcheckstate(2, checkstate.unhecked); 

the enabled property of checkedlistbox has no impact on check state of items or 2 methods.


msdn links:


update: disabling single item in checkedlistbox instead of disabling whole control not possible out of box.

if want prevent user changing check state of 1 special item, need subscribe itemcheck event of checkedlistbox:

checkedlistbox1.itemcheck += (sender, e) => {     if (e.index == 2)         e.newvalue = checkstate.unchecked; } 

this event fired before check state of item changed. e itemcheckeventargs contains item's index, current check state (currentvalue) , check state shall have afterwards (newvalue).

so setting e.newvalue = checkstate.unchecked prevents item being checked again user.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo