Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

User control can't set the enabled property of its elements

$
0
0
I have a user control which is esentially a combination of a checkbox and a textbox. I want it so that if the checkbox is clicked, the textbox be active and otherwise don't. I have this code for the clicked property of the user control:
        [Category("Appearance")]
        [Description("Gets or sets the state of the checkbox.")]
        public bool Checked
        {
            get { return checkbx.Checked; }
            set { 
                checkbx.Checked = value;
                if (checkbx.Checked == false) textbx.Enabled = false;
                else textbx.Enabled = true;
            }
        }


In the designer I got six instances of this control. Four of them are checked, two aren't - in the designer everything is fine. But as soon as I click the start debugging button, the two disabled textboxes become enabled and while running clicking the checkboxes has no effect whatsover - the corresponding textboxes are always active. Why so?
I've builded the project multiple times.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>