How to make a CheckBox unselectable?

后端 未结 10 2177
慢半拍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:07

    This code worked for me:

    public class CtrlCheckBoxReadOnly : System.Windows.Forms.CheckBox
    {
        [Category("Appearance")]
        [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
        public bool ReadOnly { get; set; }
    
        protected override void OnClick(EventArgs e)
        {
            if (!ReadOnly) base.OnClick(e);
        }
    }
    

提交回复
热议问题