C# Add Checkbox To WinForms Context Menu

c#, checkbox

Solution

The menu items have a `Checked` property (`MenuItem.Checked`, `ToolStripMenuItem.Checked`) that you can use for this purpose.

Regarding the possibility to link the context menu items to the check boxes, if you use a `ContextMenuStrip` and set `CheckOnClick` property to `true`, you can hook up the `CheckedChanged` events to the same event handler for the `ToolStripMenuItem` and `CheckBox` controls that should be "linked", and inside that event handler make sure to synchronize the `Checked` property of the controls and perform any other needed actions.

Problem

I have a series of checkboxes on a form. I want to be able to select these from a context menu as well as the form itself. The context menu is linked to the system tray icon of the application. My question is, is it possible to link the context menu to these checkboxes? Or even possible to add checkboxes to the context menu? Or even a combination?!

Original source