I am designing a logging feature in which User can select which event he wants to log. On clicking button, I am showing such type of menu:
User can select multiple Events so I need to show "Check Mark" infront of the selected option when user clicks on it.
I am unable to find any options like "Checked" or "CheckOnClick" as mentioned in this question.
I tried with ContextMenu and ContextMenuStrips but couldn't achieve Checkboxes. Any Suggestions??
Typically, a ContextMenu is displayed when the user clicks the right mouse button on a control or area of the form that the ContextMenu is bound to. You can use this method to manually display the shortcut menu at a specific location and bind it with a specific control.
In the Link to Command designer, change the following command properties. Select ContextMenu from the Create a new command listbox. This will create a command with a submenu which can be used as a context menu. Select OK, in the Link to Command dialog box.
The ContextMenuStrip control represents a shortcut menu that pops up over controls, usually when you right click them. They appear in context of some specific controls, so are called context menus. For example, Cut, Copy or Paste options.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With