When manipulating controls on a .NET windows form which of the following is best practice and why?
//Hide control from user and stop control form being useable
oControl.Enabled = false;
oControl.Visible = false;
or
//Hide control from user and stop control form being useable
oControl.Visible = false;
I’ve been using the first case and always disabling a control when hiding it, but I’ve been told that this is wrong and that I should only be hiding it. I seem to vaguely remember reading somewhere that if you don’t specifically dissable a control that it can continue to interact with the user.
Any enlightenment would be apreciated.
Enabledrefers to whether or not the user can interact with the control (i.e. if the control is grayed out or not)Visiblerefers to wehether or not the control is displayed (usually if this is false the control is not rendered at all, however not all the time apparently – see the comments of this post).If the control is not rendered then the value of the enabled propery will have no impact.