How to make a CheckBox unselectable?

后端 未结 10 2176
慢半拍i
慢半拍i 2021-01-07 16:34

I was wondering how you make a CheckBox unselectable in c#? I thought it would be something like SetSelectable (false) or something but I can\'t seem to see th

10条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 17:04

    For disabling all the checkboxes in a CheckedListBox

    for (int i = 0; i < checkedListBoxChecks.Items.Count; i++)
    {
       checkedListBoxChecks.SetItemChecked(i, true);
       //checkedListBoxChecks.Enabled = false;
       this.checkedListBoxChecks.SetItemCheckState(i, CheckState.Indeterminate);                  
    }
    
    
    private void checkedListBoxChecks_ItemCheck(object sender, ItemCheckEventArgs e)
    {
        if (e.CurrentValue == CheckState.Indeterminate)
        {
            e.NewValue = e.CurrentValue;
        }
    }
    

提交回复
热议问题