I have some items in a CheckedListBox
, I want to disable the CheckBox
of first item in it.
i.e. I want to disable the first item in the CheckedListBox
, because I want to tell the user visually that option is not available.
Combining 2 of the above partial answers worked great for me. Add your items to the list with:
myCheckedListBox.Items.Add(myItem, myState);
Where myState is CheckState.Indeterminate for items that should be disabled. Then add an event handler to keep those items from being changed:
myCheckedListBox.ItemCheck += (s, e) => { if (e.CurrentValue == CheckState.Indeterminate) e.NewValue = CheckState.Indeterminate; };
This does not allow you to use 'Indeterminate' in this list for its normal purpose but it does give a look very similar to what one would expect for a disabled item and it provides the correct behavior!