C# make winform readonly radioButton look like standard

后端 未结 3 1867
梦谈多话
梦谈多话 2021-01-21 05:51

Simple question. If I set a radiobutton in a winform project read only it\'s appearance (font color) changes to light grey. Same when I set it\'s enabled property to false,

相关标签:
3条回答
  • 2021-01-21 06:17

    Managed it by removing the text of the radiobutton and added a label next to it.

    Not the greatest solution but working...

    0 讨论(0)
  • 2021-01-21 06:18

    As an option you can add a ReadOnly property and override OnClick and call base.OnClick(e) only if !ReadOnly:

    using System;
    using System.Windows.Forms;
    public class MyRadioButton : RadioButton
    {
        public bool ReadOnly { get; set; }
        protected override void OnClick(EventArgs e)
        {
            if (!ReadOnly)
                base.OnClick(e);
        }
    }
    
    0 讨论(0)
  • 2021-01-21 06:23

    Set the AutoCheck property to false.

    0 讨论(0)
提交回复
热议问题