If you want to disable your controls without greying them out, the exact procedure to do so can be fairly complicated and depends on the control's type. I'm giving you some pointers below for TextBox
, for CheckBox
& RadioButton
, and for ComboBox
controls.
Bear in mind the possibility that this capability is not built uniformly into Winforms for a reason: A control that looks enabled, but is in fact disabled (read-only) will possibly confuse many users of your application, because dealing with your controls won't match their expectations of how Windows controls usually behave.
TextBox
Set the TextBox.ReadOnly
property to true
.
(See e.g. the article Creating a Read-Only Text Box on MSDN.)
CheckBox
(and RadioButton
)
Set the CheckBox.AutoCheck
property to false
.
Note that this also works for RadioButton
controls.
Edit: Unfortunately, I cannot retrieve my sources for making a ComboBox
read-only right now. However, it's fairly complicated and involves intercepting window messages in WndProc
. Perhaps take a look at this article on CodeProject instead.