How to disable a checkbox in a checkedlistbox?

后端 未结 11 765
遥遥无期
遥遥无期 2020-12-03 10:46

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 C

11条回答
  •  没有蜡笔的小新
    2020-12-03 11:11

    Disabling items isn't a great idea, the user will have no good feedback that click the check box won't have any effect. You cannot use custom drawing to make it obvious. Best thing to do is to simply omit the item.

    You can however easily defeat the user with the ItemCheck event:

        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) {
            if (e.Index == 0) e.NewValue = e.CurrentValue;
        }
    

提交回复
热议问题