Show checkbox for Context MenuStrip or Context Menu of a button
Don't see any of your code so I don't know how you create this menu. But in the most general terms, here is how you access the Checked
property.
((ToolStripMenuItem)contextMenuStrip.Items[0]).Checked = true; //false;
((ToolStripMenuItem)contextMenuStrip.Items[1]).Checked = true; //false;
((ToolStripMenuItem)contextMenuStrip.Items[2]).Checked = true; //false;
You can assign them as either true or false. If you have named your ToolStripItems
, then you can access them directly rather than going to the Items
array.
contextMenuStrip.event1.Checked = true; //false;
As you can see, I am using a ContextMenuStrip
.
Change the property CheckOnClick to True
In order for this to work visually, you need to ensure the "ShowCheckMargin" property is ON. Otherwise the ".Checked" property will silently do nothing.