The radio button Winform can be cancelled (RadioButton)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Have a group of selected items in the project requirements, radio and can be cancelled, but the radio button Winform provides once selected will not cancelled, after years of research and testing, we get the function request, the main code, not one one illustrates, there are code notes, to a friend in need is a reference, the Demo below.

private bool checkedStatus = false;
        /// <summary>
        /// The button to select the state, has chosen true
        /// </summary>
        public bool CheckedStatus
            get {
                return checkedStatus;
            set {
                checkedStatus = value;

        public VoidableRadioButton()
            : base()
        { }

        protected override void OnCheckedChanged(EventArgs e)
            if (!this.Checked)
                checkedStatus = false;

        protected override void OnClick(EventArgs e)
            if (checkedStatus)
                this.Checked = false;
                //Checked=false triggers CheckedChanged, so there should be reset to true
                checkedStatus = true;
            checkedStatus = !checkedStatus;

Download the source code:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Joe at November 15, 2013 - 3:33 AM