I was wondering how you make a CheckBox
unselectable in c#? I thought it would be something like SetSelectable (false) or something but I can\'t seem to see th
You can set the Enabled
property to false
:
checkBox1.Enabled = false;
In response to some comments about grayed out label: Set the Text
of the CheckBox
to the empty string, Enable
to false
and use a Label
for the text.
Drawback: No mnemonic support out of the box.
You can create one by using following code
public class ReadOnlyCheckBox : System.Windows.Forms.CheckBox
{
private bool readOnly;
protected override void OnClick(EventArgs e)
{
// pass the event up only if its not readlonly
if (!ReadOnly) base.OnClick(e);
}
public bool ReadOnly
{
get { return readOnly; }
set { readOnly = value; }
}
}
or also you can handle the checked change event and always set it back to value you want
Leverage a simple Label
using a glyph like this for its Text
: ✔ checkBox1
.
AutoCheck doesn't exist in UWP but I think you can use IsTapEnabled = false.
You can set the Enabled
property to false